1 // Copyright 2016 The etcd Authors 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package clientv3 16 17 import ( 18 "context" 19 "crypto/tls" 20 "time" 21 22 "go.uber.org/zap" 23 "google.golang.org/grpc" 24 ) 25 26 type Config struct { 27 // Endpoints is a list of URLs. 28 Endpoints []string `json:"endpoints"` 29 30 // AutoSyncInterval is the interval to update endpoints with its latest members. 31 // 0 disables auto-sync. By default auto-sync is disabled. 32 AutoSyncInterval time.Duration `json:"auto-sync-interval"` 33 34 // DialTimeout is the timeout for failing to establish a connection. 35 DialTimeout time.Duration `json:"dial-timeout"` 36 37 // DialKeepAliveTime is the time after which client pings the server to see if 38 // transport is alive. 39 DialKeepAliveTime time.Duration `json:"dial-keep-alive-time"` 40 41 // DialKeepAliveTimeout is the time that the client waits for a response for the 42 // keep-alive probe. If the response is not received in this time, the connection is closed. 43 DialKeepAliveTimeout time.Duration `json:"dial-keep-alive-timeout"` 44 45 // MaxCallSendMsgSize is the client-side request send limit in bytes. 46 // If 0, it defaults to 2.0 MiB (2 * 1024 * 1024). 47 // Make sure that "MaxCallSendMsgSize" < server-side default send/recv limit. 48 // ("--max-request-bytes" flag to etcd or "embed.Config.MaxRequestBytes"). 49 MaxCallSendMsgSize int 50 51 // MaxCallRecvMsgSize is the client-side response receive limit. 52 // If 0, it defaults to "math.MaxInt32", because range response can 53 // easily exceed request send limits. 54 // Make sure that "MaxCallRecvMsgSize" >= server-side default send/recv limit. 55 // ("--max-request-bytes" flag to etcd or "embed.Config.MaxRequestBytes"). 56 MaxCallRecvMsgSize int 57 58 // TLS holds the client secure credentials, if any. 59 TLS *tls.Config 60 61 // Username is a user name for authentication. 62 Username string `json:"username"` 63 64 // Password is a password for authentication. 65 Password string `json:"password"` 66 67 // RejectOldCluster when set will refuse to create a client against an outdated cluster. 68 RejectOldCluster bool `json:"reject-old-cluster"` 69 70 // DialOptions is a list of dial options for the grpc client (e.g., for interceptors). 71 // For example, pass "grpc.WithBlock()" to block until the underlying connection is up. 72 // Without this, Dial returns immediately and connecting the server happens in background. 73 DialOptions []grpc.DialOption 74 75 // Context is the default client context; it can be used to cancel grpc dial out and 76 // other operations that do not have an explicit context. 77 Context context.Context 78 79 // Logger sets client-side logger. 80 // If nil, fallback to building LogConfig. 81 Logger *zap.Logger 82 83 // LogConfig configures client-side logger. 84 // If nil, use the default logger. 85 // TODO: configure gRPC logger 86 LogConfig *zap.Config 87 88 // PermitWithoutStream when set will allow client to send keepalive pings to server without any active streams(RPCs). 89 PermitWithoutStream bool `json:"permit-without-stream"` 90 91 // MaxUnaryRetries is the maximum number of retries for unary RPCs. 92 MaxUnaryRetries uint `json:"max-unary-retries"` 93 94 // BackoffWaitBetween is the wait time before retrying an RPC. 95 BackoffWaitBetween time.Duration `json:"backoff-wait-between"` 96 97 // BackoffJitterFraction is the jitter fraction to randomize backoff wait time. 98 BackoffJitterFraction float64 `json:"backoff-jitter-fraction"` 99 100 // TODO: support custom balancer picker 101 } 102