loadbalancer

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AlgorithmRoundRobin         = algorithm.RoundRobin
	AlgorithmRandom             = algorithm.Random
	AlgorithmWeightedRoundRobin = algorithm.WeightedRoundRobin
	AlgorithmLeastConnections   = algorithm.LeastConnections
	AlgorithmSemantic           = algorithm.Semantic
)

Variables

This section is empty.

Functions

func Algorithms

func Algorithms() []string

func IsValidAlgorithm

func IsValidAlgorithm(name string) bool

Types

type BaseFactory

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

func (*BaseFactory) CreateStrategy

func (f *BaseFactory) CreateStrategy(input StrategyInput) (Strategy, error)

type Factory

type Factory interface {
	CreateStrategy(input StrategyInput) (Strategy, error)
}

func NewBaseFactory

func NewBaseFactory(
	embeddingRepo embedding.Repository,
	serviceLocator factory.EmbeddingServiceLocator,
) Factory

type HealthStatus

type HealthStatus struct {
	Healthy    bool
	LastCheck  time.Time
	LastError  error
	Failures   int
	ActiveConn int32
}

type LoadBalancer

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

func NewLoadBalancer

func NewLoadBalancer(
	factory Factory,
	pool Pool,
	logger *slog.Logger,
	cacheClient cache.Client,
) (*LoadBalancer, error)

func (*LoadBalancer) Close

func (lb *LoadBalancer) Close()

func (*LoadBalancer) NextBackend

func (lb *LoadBalancer) NextBackend(
	req *infracontext.RequestContext,
	exclude map[ids.RegistryID]struct{},
) (*registry.Registry, error)

func (*LoadBalancer) ReportFailure

func (lb *LoadBalancer) ReportFailure(b *registry.Registry, err error)

func (*LoadBalancer) ReportSuccess

func (lb *LoadBalancer) ReportSuccess(b *registry.Registry)

func (*LoadBalancer) UpdateBackendHealth

func (lb *LoadBalancer) UpdateBackendHealth(b *registry.Registry, healthy bool, err error)

type Pool

type Pool struct {
	ID              string
	Registries      []*registry.Registry
	Weights         map[ids.RegistryID]int
	Algorithm       string
	EmbeddingConfig *registry.EmbeddingConfig
}

type Strategy

type Strategy interface {
	Next(req *infracontext.RequestContext, exclude map[ids.RegistryID]struct{}) *registry.Registry
	Name() string
}

type StrategyInput

type StrategyInput struct {
	Algorithm       string
	Registries      []*registry.Registry
	Weights         map[ids.RegistryID]int
	EmbeddingConfig *embedding.Config
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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