options.go 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. "google.golang.org/grpc"
  18. )
  19. var (
  20. // Disable gRPC internal retrial logic
  21. // TODO: enable when gRPC retry is stable (FailFast=false)
  22. // Reference:
  23. // - https://github.com/grpc/grpc-go/issues/1532
  24. // - https://github.com/grpc/proposal/blob/master/A6-client-retries.md
  25. defaultFailFast = grpc.FailFast(true)
  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. )
  36. // defaultCallOpts defines a list of default "gRPC.CallOption".
  37. // Some options are exposed to "clientv3.Config".
  38. // Defaults will be overridden by the settings in "clientv3.Config".
  39. var defaultCallOpts = []grpc.CallOption{defaultFailFast, defaultMaxCallSendMsgSize, defaultMaxCallRecvMsgSize}
  40. // MaxLeaseTTL is the maximum lease TTL value
  41. const MaxLeaseTTL = 9000000000