Documentation
¶
Overview ¶
Package balancer provides gRPC load balancing functionality for service discovery and routing in distributed systems.
Index ¶
- Variables
- func New(opts ...Option) selector.Selector
- func NewBuilder(opts ...Option) selector.Builder
- func NewFilter() selector.NodeFilter
- func RegisterMasterBalancer(rt routetable.RouteTable)
- func RegisterReaderBalancer(rt routetable.RouteTable)
- type Balancer
- type Builder
- type Option
- type Trailer
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // ReaderBalancerRegistered indicates whether the reader balancer has been registered. ReaderBalancerRegistered atomic.Bool // MasterBalancerRegistered indicates whether the master balancer has been registered. MasterBalancerRegistered atomic.Bool )
Functions ¶
func NewBuilder ¶
NewBuilder returns a selector builder with wrr balancer
func NewFilter ¶
func NewFilter() selector.NodeFilter
NewFilter creates a node filter that filters nodes based on color. It returns a selector.NodeFilter that selects nodes matching the color from context.
func RegisterMasterBalancer ¶
func RegisterMasterBalancer(rt routetable.RouteTable)
RegisterMasterBalancer registers a balancer for master nodes. It uses the provided route table for routing decisions.
func RegisterReaderBalancer ¶
func RegisterReaderBalancer(rt routetable.RouteTable)
RegisterReaderBalancer registers a balancer for reader nodes. It uses the provided route table for routing decisions.
Types ¶
type Balancer ¶
type Balancer struct {
// contains filtered or unexported fields
}
Balancer is a weighted round-robin load balancer that supports route tables.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is a selector builder for creating weighted round-robin balancers.
type Option ¶
type Option func(o *options)
Option is a function that configures the selector options.
func WithBalancerType ¶
WithBalancerType sets the balancer type.
func WithRouteTable ¶
func WithRouteTable(rt routetable.RouteTable) Option
WithRouteTable sets the route table for the balancer.