|
|
@@ -39,11 +39,14 @@ const (
|
|
|
ClusterStateFlagNew = "new"
|
|
|
ClusterStateFlagExisting = "existing"
|
|
|
|
|
|
- DefaultName = "default"
|
|
|
- DefaultMaxSnapshots = 5
|
|
|
- DefaultMaxWALs = 5
|
|
|
- DefaultMaxTxnOps = uint(128)
|
|
|
- DefaultMaxRequestBytes = 1.5 * 1024 * 1024
|
|
|
+ DefaultName = "default"
|
|
|
+ DefaultMaxSnapshots = 5
|
|
|
+ DefaultMaxWALs = 5
|
|
|
+ DefaultMaxTxnOps = uint(128)
|
|
|
+ DefaultMaxRequestBytes = 1.5 * 1024 * 1024
|
|
|
+ DefaultGRPCKeepAliveMinTime = 5 * time.Second
|
|
|
+ DefaultGRPCKeepAliveInterval = 2 * time.Hour
|
|
|
+ DefaultGRPCKeepAliveTimeout = 20 * time.Second
|
|
|
|
|
|
DefaultListenPeerURLs = "http://localhost:2380"
|
|
|
DefaultListenClientURLs = "http://localhost:2379"
|
|
|
@@ -93,6 +96,23 @@ type Config struct {
|
|
|
MaxTxnOps uint `json:"max-txn-ops"`
|
|
|
MaxRequestBytes uint `json:"max-request-bytes"`
|
|
|
|
|
|
+ // gRPC server options
|
|
|
+
|
|
|
+ // GRPCKeepAliveMinTime is the minimum interval that a client should
|
|
|
+ // wait before pinging server. When client pings "too fast", server
|
|
|
+ // sends goaway and closes the connection (errors: too_many_pings,
|
|
|
+ // http2.ErrCodeEnhanceYourCalm). When too slow, nothing happens.
|
|
|
+ // Server expects client pings only when there is any active streams
|
|
|
+ // (PermitWithoutStream is set false).
|
|
|
+ GRPCKeepAliveMinTime time.Duration `json:"grpc-keepalive-min-time"`
|
|
|
+ // GRPCKeepAliveInterval is the frequency of server-to-client ping
|
|
|
+ // to check if a connection is alive. Close a non-responsive connection
|
|
|
+ // after an additional duration of Timeout. 0 to disable.
|
|
|
+ GRPCKeepAliveInterval time.Duration `json:"grpc-keepalive-interval"`
|
|
|
+ // GRPCKeepAliveTimeout is the additional duration of wait
|
|
|
+ // before closing a non-responsive connection. 0 to disable.
|
|
|
+ GRPCKeepAliveTimeout time.Duration `json:"grpc-keepalive-timeout"`
|
|
|
+
|
|
|
// clustering
|
|
|
|
|
|
APUrls, ACUrls []url.URL
|
|
|
@@ -181,25 +201,28 @@ func NewConfig() *Config {
|
|
|
lcurl, _ := url.Parse(DefaultListenClientURLs)
|
|
|
acurl, _ := url.Parse(DefaultAdvertiseClientURLs)
|
|
|
cfg := &Config{
|
|
|
- CorsInfo: &cors.CORSInfo{},
|
|
|
- MaxSnapFiles: DefaultMaxSnapshots,
|
|
|
- MaxWalFiles: DefaultMaxWALs,
|
|
|
- Name: DefaultName,
|
|
|
- SnapCount: etcdserver.DefaultSnapCount,
|
|
|
- MaxTxnOps: DefaultMaxTxnOps,
|
|
|
- MaxRequestBytes: DefaultMaxRequestBytes,
|
|
|
- TickMs: 100,
|
|
|
- ElectionMs: 1000,
|
|
|
- LPUrls: []url.URL{*lpurl},
|
|
|
- LCUrls: []url.URL{*lcurl},
|
|
|
- APUrls: []url.URL{*apurl},
|
|
|
- ACUrls: []url.URL{*acurl},
|
|
|
- ClusterState: ClusterStateFlagNew,
|
|
|
- InitialClusterToken: "etcd-cluster",
|
|
|
- StrictReconfigCheck: true,
|
|
|
- Metrics: "basic",
|
|
|
- EnableV2: true,
|
|
|
- AuthToken: "simple",
|
|
|
+ CorsInfo: &cors.CORSInfo{},
|
|
|
+ MaxSnapFiles: DefaultMaxSnapshots,
|
|
|
+ MaxWalFiles: DefaultMaxWALs,
|
|
|
+ Name: DefaultName,
|
|
|
+ SnapCount: etcdserver.DefaultSnapCount,
|
|
|
+ MaxTxnOps: DefaultMaxTxnOps,
|
|
|
+ MaxRequestBytes: DefaultMaxRequestBytes,
|
|
|
+ GRPCKeepAliveMinTime: DefaultGRPCKeepAliveMinTime,
|
|
|
+ GRPCKeepAliveInterval: DefaultGRPCKeepAliveInterval,
|
|
|
+ GRPCKeepAliveTimeout: DefaultGRPCKeepAliveTimeout,
|
|
|
+ TickMs: 100,
|
|
|
+ ElectionMs: 1000,
|
|
|
+ LPUrls: []url.URL{*lpurl},
|
|
|
+ LCUrls: []url.URL{*lcurl},
|
|
|
+ APUrls: []url.URL{*apurl},
|
|
|
+ ACUrls: []url.URL{*acurl},
|
|
|
+ ClusterState: ClusterStateFlagNew,
|
|
|
+ InitialClusterToken: "etcd-cluster",
|
|
|
+ StrictReconfigCheck: true,
|
|
|
+ Metrics: "basic",
|
|
|
+ EnableV2: true,
|
|
|
+ AuthToken: "simple",
|
|
|
}
|
|
|
cfg.InitialCluster = cfg.InitialClusterFromName(cfg.Name)
|
|
|
return cfg
|