config.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. *
  3. * Copyright 2023 gRPC authors.
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. */
  18. package weightedroundrobin
  19. import (
  20. iserviceconfig "google.golang.org/grpc/internal/serviceconfig"
  21. "google.golang.org/grpc/serviceconfig"
  22. )
  23. type lbConfig struct {
  24. serviceconfig.LoadBalancingConfig `json:"-"`
  25. // Whether to enable out-of-band utilization reporting collection from the
  26. // endpoints. By default, per-request utilization reporting is used.
  27. EnableOOBLoadReport bool `json:"enableOobLoadReport,omitempty"`
  28. // Load reporting interval to request from the server. Note that the
  29. // server may not provide reports as frequently as the client requests.
  30. // Used only when enable_oob_load_report is true. Default is 10 seconds.
  31. OOBReportingPeriod iserviceconfig.Duration `json:"oobReportingPeriod,omitempty"`
  32. // A given endpoint must report load metrics continuously for at least this
  33. // long before the endpoint weight will be used. This avoids churn when
  34. // the set of endpoint addresses changes. Takes effect both immediately
  35. // after we establish a connection to an endpoint and after
  36. // weight_expiration_period has caused us to stop using the most recent
  37. // load metrics. Default is 10 seconds.
  38. BlackoutPeriod iserviceconfig.Duration `json:"blackoutPeriod,omitempty"`
  39. // If a given endpoint has not reported load metrics in this long,
  40. // then we stop using the reported weight. This ensures that we do
  41. // not continue to use very stale weights. Once we stop using a stale
  42. // value, if we later start seeing fresh reports again, the
  43. // blackout_period applies. Defaults to 3 minutes.
  44. WeightExpirationPeriod iserviceconfig.Duration `json:"weightExpirationPeriod,omitempty"`
  45. // How often endpoint weights are recalculated. Default is 1 second.
  46. WeightUpdatePeriod iserviceconfig.Duration `json:"weightUpdatePeriod,omitempty"`
  47. // The multiplier used to adjust endpoint weights with the error rate
  48. // calculated as eps/qps. Default is 1.0.
  49. ErrorUtilizationPenalty float64 `json:"errorUtilizationPenalty,omitempty"`
  50. }