balancer

package
v1.2.9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "consistenthashing" // Name of the balancer.
	Key  = "consistenthashkey" // Key for the consistent hash.
)

Package-level constants for the balancer name and consistent hash key.

Variables

This section is empty.

Functions

This section is empty.

Types

type Balancer added in v1.2.8

type Balancer struct {
	// contains filtered or unexported fields
}

func (*Balancer) Close added in v1.2.8

func (b *Balancer) Close()

func (*Balancer) ResolverError added in v1.2.8

func (b *Balancer) ResolverError(err error)

func (*Balancer) UpdateClientConnState added in v1.2.8

func (b *Balancer) UpdateClientConnState(s balancer.ClientConnState) error

func (*Balancer) UpdateSubConnState added in v1.2.8

func (b *Balancer) UpdateSubConnState(sc balancer.SubConn, state balancer.SubConnState)

type Builder added in v1.2.8

type Builder interface {
	balancer.Builder      // Interface for building balancers.
	balancer.ConfigParser // Interface for parsing balancer configurations.
}

Builder defines the interface for the consistent hashing balancer builder.

func NewBuilder added in v1.2.8

func NewBuilder(fn consistent.Hasher) Builder

NewBuilder initializes a new builder with the given hashing function.

type Config added in v1.2.8

type Config struct {
	serviceconfig.LoadBalancingConfig `json:"-"` // Embedding the base load balancing config.
	PartitionCount                    int        `json:"partitionCount,omitempty"`    // Number of partitions in the consistent hash ring.
	ReplicationFactor                 int        `json:"replicationFactor,omitempty"` // Number of replicas for each member.
	Load                              float64    `json:"load,omitempty"`              // Load factor for balancing traffic.
	PickerWidth                       int        `json:"pickerWidth,omitempty"`       // Number of closest members to consider in the picker.
}

Config represents the configuration for the consistent hashing balancer.

func (*Config) ServiceConfigJSON added in v1.2.8

func (c *Config) ServiceConfigJSON() (string, error)

ServiceConfigJSON generates the JSON representation of the load balancer configuration.

type ConsistentMember added in v1.2.8

type ConsistentMember struct {
	balancer.SubConn // Embedded SubConn for the gRPC connection.
	// contains filtered or unexported fields
}

ConsistentMember represents a member in the consistent hashing ring.

func (ConsistentMember) String added in v1.2.8

func (s ConsistentMember) String() string

String returns the name of the ConsistentMember.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL