-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathagent_options.go
More file actions
145 lines (114 loc) · 3.87 KB
/
agent_options.go
File metadata and controls
145 lines (114 loc) · 3.87 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package gocbcorex
import (
"crypto/tls"
"strings"
"time"
"go.uber.org/zap/zapcore"
"go.uber.org/zap"
)
type AgentReconfigureOptions struct {
TLSConfig *tls.Config
Authenticator Authenticator
BucketName string
}
// Temporary options.
type AgentOptions struct {
Logger *zap.Logger
TLSConfig *tls.Config
Authenticator Authenticator
BucketName string
SeedConfig SeedConfig
CompressionConfig CompressionConfig
IoConfig IoConfig
ConfigPollerConfig ConfigPollerConfig
RetryManager RetryManager
HTTPConfig HTTPConfig
NodesWatcher *NodesWatcherHttp
DisableMetrics bool
}
func (opts AgentOptions) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddString("bucket-name", opts.BucketName)
if err := enc.AddObject("seed-config", opts.SeedConfig); err != nil {
return err
}
if err := enc.AddObject("compression-config", opts.CompressionConfig); err != nil {
return err
}
if err := enc.AddObject("poller-config", opts.ConfigPollerConfig); err != nil {
return err
}
if err := enc.AddObject("http-config", opts.HTTPConfig); err != nil {
return err
}
return nil
}
// SeedConfig specifies initial seed configuration options such as addresses.
type SeedConfig struct {
HTTPAddrs []string
MemdAddrs []string
// The http address of the cluster node running on the same machine as this
// instance of gocbcorex. Used to record how many requests can be serviced
// locally.
LocalNodeAddr string
// The server group to which this instance of gocbcorex belongs.
ServerGroup string
}
func (c SeedConfig) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddString("http-addresses", strings.Join(c.HTTPAddrs, ","))
enc.AddString("memd-addresses", strings.Join(c.MemdAddrs, ","))
return nil
}
// CompressionConfig specifies options for controlling compression applied to documents using KV.
type CompressionConfig struct {
EnableCompression bool
DisableDecompression bool
MinSize int
MinRatio float64
}
func (c CompressionConfig) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddBool("enabled", c.EnableCompression)
enc.AddBool("decompression-disabled", c.DisableDecompression)
enc.AddInt("min-size", c.MinSize)
enc.AddFloat64("min-ratio", c.MinRatio)
return nil
}
// IoConfig specifies options for controlling io setup.
type IoConfig struct {
ConnectionPoolSize uint
}
func (c IoConfig) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddUint("connection-pool-size", c.ConnectionPoolSize)
return nil
}
// ConfigPollerConfig specifies options for controlling the cluster configuration pollers.
type ConfigPollerConfig struct {
HTTPRedialPeriod time.Duration
HTTPRetryDelay time.Duration
HTTPMaxWait time.Duration
// CccpMaxWait time.Duration
// CccpPollPeriod time.Duration
}
func (c ConfigPollerConfig) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddString("redial-period", c.HTTPRedialPeriod.String())
enc.AddString("retry-delay", c.HTTPRetryDelay.String())
enc.AddString("max-wait", c.HTTPMaxWait.String())
return nil
}
// HTTPConfig specifies http related configuration options.
type HTTPConfig struct {
// MaxIdleConns controls the maximum number of idle (keep-alive) connections across all hosts.
MaxIdleConns int
// MaxIdleConnsPerHost controls the maximum idle (keep-alive) connections to keep per-host.
MaxIdleConnsPerHost int
ConnectTimeout time.Duration
// IdleConnectionTimeout is the maximum amount of time an idle (keep-alive) connection will remain idle before
// closing itself.
IdleConnectionTimeout time.Duration
}
func (c HTTPConfig) MarshalLogObject(enc zapcore.ObjectEncoder) error {
enc.AddInt("max-idle-conns", c.MaxIdleConns)
enc.AddInt("max-idle-conns-per-host", c.MaxIdleConnsPerHost)
enc.AddString("connection-timeout", c.ConnectTimeout.String())
enc.AddString("idle-connection-timeout", c.IdleConnectionTimeout.String())
return nil
}