-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtime.go
72 lines (57 loc) · 1.71 KB
/
runtime.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package enthasura
import (
hasura_api "github.com/minskylab/hasura-api"
"github.com/pkg/errors"
)
type Runtime struct {
hasura *hasura_api.HasuraClient
}
func NewRuntime(options ...hasura_api.HasuraClientOption) (*Runtime, error) {
client, err := hasura_api.NewHasuraClient(options...)
if err != nil {
return nil, errors.WithStack(err)
}
return &Runtime{
hasura: client,
}, nil
}
// type EphemeralRuntime struct {
// Client *resty.Client
// Config *HasuraConfig
// AdminSecret string
// operatedTables map[string]map[string]time.Time
// }
// type EphemeralRuntimeOptions struct {
// configFilepaths []string
// envFilepaths []string
// }
// type EphemeralRuntimeOption func(*EphemeralRuntimeOptions)
// func WithConfigFilepath(filepath ...string) EphemeralRuntimeOption {
// return func(options *EphemeralRuntimeOptions) {
// options.configFilepaths = filepath
// }
// }
// func WithEnvFilepath(filepath ...string) EphemeralRuntimeOption {
// return func(options *EphemeralRuntimeOptions) {
// options.envFilepaths = filepath
// }
// }
// func NewEphemeralRuntime(options ...EphemeralRuntimeOption) (*EphemeralRuntime, error) {
// optionsStruct := new(EphemeralRuntimeOptions)
// for _, opt := range options {
// opt(optionsStruct)
// }
// if err := godotenv.Load(optionsStruct.envFilepaths...); err != nil {
// logrus.Warn("Error loading .env file", err)
// }
// conf, err := ConfigFromFile(optionsStruct.configFilepaths...)
// if err != nil {
// return nil, errors.WithStack(err)
// }
// logrus.Info(conf.Endpoint)
// return &EphemeralRuntime{
// Client: resty.New(),
// AdminSecret: config.Getenv("HASURA_GRAPHQL_ADMIN_SECRET", ""),
// Config: conf,
// }, nil
// }