-
Notifications
You must be signed in to change notification settings - Fork 138
/
backend.go
58 lines (49 loc) · 1.99 KB
/
backend.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
package types
import (
"time"
)
type BackendsV2 struct {
Backends []BackendV2 `mapstructure:"backends"`
MaxIdleConnsPerHost int `mapstructure:"maxIdleConnsPerHost"`
ConcurrencyLimitPerServer int `mapstructure:"concurrencyLimit"`
Timeouts Timeouts `mapstructure:"timeouts"`
KeepAliveInterval time.Duration `mapstructure:"keepAliveInterval"`
MaxTries int `mapstructure:"maxTries"`
MaxBatchSize *int `mapstructure:"maxBatchSize"`
}
type BackendV2 struct {
GroupName string `mapstructure:"groupName"`
Protocol string `mapstructure:"protocol"`
LBMethod string `mapstructure:"lbMethod"` // Valid: rr/roundrobin, broadcast/all
Servers []string `mapstructure:"servers"`
Timeouts *Timeouts `mapstructure:"timeouts"`
ConcurrencyLimit *int `mapstructure:"concurrencyLimit"`
KeepAliveInterval *time.Duration `mapstructure:"keepAliveInterval"`
MaxIdleConnsPerHost *int `mapstructure:"maxIdleConnsPerHost"`
MaxTries *int `mapstructure:"maxTries"`
MaxBatchSize *int `mapstructure:"maxBatchSize"`
BackendOptions map[string]interface{} `mapstructure:"backendOptions"`
}
func (b *BackendV2) FillDefaults() {
if b.Timeouts == nil {
b.Timeouts = &Timeouts{}
}
if b.Timeouts.Render == 0 {
b.Timeouts.Render = 10000 * time.Second
}
if b.Timeouts.Find == 0 {
b.Timeouts.Find = 10000 * time.Second
}
if b.Timeouts.Connect == 0 {
b.Timeouts.Connect = 200 * time.Millisecond
}
}
// CarbonSearch is a structure that contains carbonsearch related configuration bits
type CarbonSearch struct {
Backend string `mapstructure:"backend"`
Prefix string `mapstructure:"prefix"`
}
type CarbonSearchV2 struct {
BackendsV2
Prefix string `mapstructure:"prefix"`
}