-
Notifications
You must be signed in to change notification settings - Fork 59
/
options.go
49 lines (41 loc) · 1.23 KB
/
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
package proxy
import "time"
// Options defines per datasource options for creating the proxy dialer.
type Options struct {
Enabled bool
// DatasourceName is the name of the datasource the proxy will be used to communicate with.
DatasourceName string
// DatasourceType is the type of the datasource the proxy will be used to communicate with.
// It should be the value assigned to the type property in a datasource provisioning file (e.g mysql, prometheus)
DatasourceType string
Auth *AuthOptions
Timeouts *TimeoutOptions
ClientCfg *ClientCfg
}
// AuthOptions socks5 username and password options.
// Every datasource can have separate credentials to the proxy.
type AuthOptions struct {
Username string
Password string
}
// TimeoutOptions timeout/connection options.
type TimeoutOptions struct {
Timeout time.Duration
KeepAlive time.Duration
}
// DefaultTimeoutOptions default timeout/connection options for the proxy.
var DefaultTimeoutOptions = TimeoutOptions{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}
func (o *Options) setDefaults() {
if o == nil {
return
}
if o.Timeouts == nil {
o.Timeouts = &DefaultTimeoutOptions
}
if o.ClientCfg == nil {
o.ClientCfg = getConfigFromEnv()
}
}