options.go 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Copyright 2017 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. package clientv3
  15. import (
  16. "math"
  17. "time"
  18. "google.golang.org/grpc"
  19. )
  20. var (
  21. // client-side handling retrying of request failures where data was not written to the wire or
  22. // where server indicates it did not process the data. gRPC default is default is "FailFast(true)"
  23. // but for etcd we default to "FailFast(false)" to minimize client request error responses due to
  24. // transient failures.
  25. defaultFailFast = grpc.FailFast(false)
  26. // client-side request send limit, gRPC default is math.MaxInt32
  27. // Make sure that "client-side send limit < server-side default send/recv limit"
  28. // Same value as "embed.DefaultMaxRequestBytes" plus gRPC overhead bytes
  29. defaultMaxCallSendMsgSize = grpc.MaxCallSendMsgSize(2 * 1024 * 1024)
  30. // client-side response receive limit, gRPC default is 4MB
  31. // Make sure that "client-side receive limit >= server-side default send/recv limit"
  32. // because range response can easily exceed request send limits
  33. // Default to math.MaxInt32; writes exceeding server-side send limit fails anyway
  34. defaultMaxCallRecvMsgSize = grpc.MaxCallRecvMsgSize(math.MaxInt32)
  35. // client-side non-streaming retry limit, only applied to requests where server responds with
  36. // a error code clearly indicating it was unable to process the request such as codes.Unavailable.
  37. // If set to 0, retry is disabled.
  38. defaultUnaryMaxRetries uint = 100
  39. // client-side streaming retry limit, only applied to requests where server responds with
  40. // a error code clearly indicating it was unable to process the request such as codes.Unavailable.
  41. // If set to 0, retry is disabled.
  42. defaultStreamMaxRetries = ^uint(0) // max uint
  43. // client-side retry backoff wait between requests.
  44. defaultBackoffWaitBetween = 25 * time.Millisecond
  45. // client-side retry backoff default jitter fraction.
  46. defaultBackoffJitterFraction = 0.10
  47. )
  48. // defaultCallOpts defines a list of default "gRPC.CallOption".
  49. // Some options are exposed to "clientv3.Config".
  50. // Defaults will be overridden by the settings in "clientv3.Config".
  51. var defaultCallOpts = []grpc.CallOption{defaultFailFast, defaultMaxCallSendMsgSize, defaultMaxCallRecvMsgSize}
  52. // MaxLeaseTTL is the maximum lease TTL value
  53. const MaxLeaseTTL = 9000000000