...

Source file src/google.golang.org/grpc/balancer/weightedroundrobin/config.go

Documentation: google.golang.org/grpc/balancer/weightedroundrobin

     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  
    19  package weightedroundrobin
    20  
    21  import (
    22  	iserviceconfig "google.golang.org/grpc/internal/serviceconfig"
    23  	"google.golang.org/grpc/serviceconfig"
    24  )
    25  
    26  type lbConfig struct {
    27  	serviceconfig.LoadBalancingConfig `json:"-"`
    28  
    29  	// Whether to enable out-of-band utilization reporting collection from the
    30  	// endpoints.  By default, per-request utilization reporting is used.
    31  	EnableOOBLoadReport bool `json:"enableOobLoadReport,omitempty"`
    32  
    33  	// Load reporting interval to request from the server.  Note that the
    34  	// server may not provide reports as frequently as the client requests.
    35  	// Used only when enable_oob_load_report is true.  Default is 10 seconds.
    36  	OOBReportingPeriod iserviceconfig.Duration `json:"oobReportingPeriod,omitempty"`
    37  
    38  	// A given endpoint must report load metrics continuously for at least this
    39  	// long before the endpoint weight will be used.  This avoids churn when
    40  	// the set of endpoint addresses changes.  Takes effect both immediately
    41  	// after we establish a connection to an endpoint and after
    42  	// weight_expiration_period has caused us to stop using the most recent
    43  	// load metrics.  Default is 10 seconds.
    44  	BlackoutPeriod iserviceconfig.Duration `json:"blackoutPeriod,omitempty"`
    45  
    46  	// If a given endpoint has not reported load metrics in this long,
    47  	// then we stop using the reported weight.  This ensures that we do
    48  	// not continue to use very stale weights.  Once we stop using a stale
    49  	// value, if we later start seeing fresh reports again, the
    50  	// blackout_period applies.  Defaults to 3 minutes.
    51  	WeightExpirationPeriod iserviceconfig.Duration `json:"weightExpirationPeriod,omitempty"`
    52  
    53  	// How often endpoint weights are recalculated.  Default is 1 second.
    54  	WeightUpdatePeriod iserviceconfig.Duration `json:"weightUpdatePeriod,omitempty"`
    55  
    56  	// The multiplier used to adjust endpoint weights with the error rate
    57  	// calculated as eps/qps. Default is 1.0.
    58  	ErrorUtilizationPenalty float64 `json:"errorUtilizationPenalty,omitempty"`
    59  }
    60  

View as plain text