forked from firebolt-db/firebolt-go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdriver_options.go
53 lines (43 loc) · 1.14 KB
/
driver_options.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
package fireboltgosdk
type driverOption func(d *FireboltDriver)
// WithEngineUrl defines engine url for the driver
func WithEngineUrl(engineUrl string) driverOption {
return func(d *FireboltDriver) {
d.engineUrl = engineUrl
}
}
// WithDatabaseName defines database name for the driver
func WithDatabaseName(databaseName string) driverOption {
return func(d *FireboltDriver) {
d.databaseName = databaseName
}
}
// WithClientParams defines client parameters for the driver
func WithClientParams(accountID string, token string, userAgent string) driverOption {
return func(d *FireboltDriver) {
cl := &ClientImpl{
ConnectedToSystemEngine: true,
}
cl.AccountID = accountID
cl.UserAgent = userAgent
cl.parameterGetter = cl.getQueryParams
cl.accessTokenGetter = func() (string, error) {
return token, nil
}
d.client = cl
}
}
// FireboltConnectorWithOptions builds a custom connector
func FireboltConnectorWithOptions(opts ...driverOption) *FireboltConnector {
d := &FireboltDriver{}
for _, opt := range opts {
opt(d)
}
return &FireboltConnector{
d.engineUrl,
d.databaseName,
d.client,
map[string]string{},
d,
}
}