package weight

import "google.golang.org/grpc/internal/balancer/weight"

Package weight contains utilities to manage endpoint weights. Weights are used by LB policies such as ringhash to distribute load across multiple endpoints.

Index

Functions

func Set

func Set(endpoint resolver.Endpoint, epInfo EndpointInfo) resolver.Endpoint

Set returns a copy of endpoint in which the Attributes field is updated with EndpointInfo.

Types

type EndpointInfo

type EndpointInfo struct {
	Weight uint32
}

EndpointInfo will be stored in the Attributes field of Endpoints in order to use the ringhash balancer.

func FromEndpoint

func FromEndpoint(endpoint resolver.Endpoint) EndpointInfo

FromEndpoint returns the EndpointInfo stored in the Attributes field of an endpoint. It returns an empty EndpointInfo if attribute is not found.

func (EndpointInfo) Equal

func (a EndpointInfo) Equal(o any) bool

Equal allows the values to be compared by Attributes.Equal.

func (EndpointInfo) String

func (a EndpointInfo) String() string

String returns a human-readable representation of EndpointInfo. This method is intended for logging, testing, and debugging purposes only. Do not rely on the output format, as it is not guaranteed to remain stable.

Source Files

weight.go

Version
v1.73.0-dev
Published
Apr 3, 2025
Platform
js/wasm
Imports
2 packages
Last checked
12 minutes ago

Tools for package owners.