balancer

package
v0.0.0-...-7c7d0f6 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeStrategy

func NormalizeStrategy(strategy string) string

Types

type Balancer

type Balancer interface {
	Next(ctx SelectionContext) *models.ModelConfig
	Models() []*models.ModelConfig
	AddModel(model *models.ModelConfig)
	RemoveModel(modelName string)
	Size() int
}

Balancer chooses one upstream model endpoint for each request.

func New

func New(strategy string) Balancer

type ClientStickyBalancer

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

func NewClientStickyBalancer

func NewClientStickyBalancer() *ClientStickyBalancer

func (*ClientStickyBalancer) AddModel

func (sb *ClientStickyBalancer) AddModel(model *models.ModelConfig)

func (*ClientStickyBalancer) Models

func (sb *ClientStickyBalancer) Models() []*models.ModelConfig

func (*ClientStickyBalancer) Next

func (*ClientStickyBalancer) RemoveModel

func (sb *ClientStickyBalancer) RemoveModel(modelName string)

func (*ClientStickyBalancer) Size

func (sb *ClientStickyBalancer) Size() int

type LatencyBalancer

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

func NewLatencyBalancer

func NewLatencyBalancer() *LatencyBalancer

func (*LatencyBalancer) AddModel

func (lb *LatencyBalancer) AddModel(model *models.ModelConfig)

func (*LatencyBalancer) Models

func (lb *LatencyBalancer) Models() []*models.ModelConfig

func (*LatencyBalancer) Next

func (*LatencyBalancer) Observe

func (lb *LatencyBalancer) Observe(model *models.ModelConfig, latency time.Duration, success bool)

func (*LatencyBalancer) RemoveModel

func (lb *LatencyBalancer) RemoveModel(modelName string)

func (*LatencyBalancer) Size

func (lb *LatencyBalancer) Size() int

type Observer

type Observer interface {
	Observe(model *models.ModelConfig, latency time.Duration, success bool)
}

type RoundRobinBalancer

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

RoundRobinBalancer picks endpoints in order.

func NewRoundRobinBalancer

func NewRoundRobinBalancer() *RoundRobinBalancer

func (*RoundRobinBalancer) AddModel

func (rb *RoundRobinBalancer) AddModel(model *models.ModelConfig)

func (*RoundRobinBalancer) Models

func (rb *RoundRobinBalancer) Models() []*models.ModelConfig

func (*RoundRobinBalancer) Next

func (*RoundRobinBalancer) RemoveModel

func (rb *RoundRobinBalancer) RemoveModel(modelName string)

func (*RoundRobinBalancer) Size

func (rb *RoundRobinBalancer) Size() int

type SelectionContext

type SelectionContext struct {
	ClientKey      string
	KeyID          int
	KeyName        string
	TeamID         int
	OrganizationID int
	ModelGroup     string
	Path           string
	ClientIP       string
	Headers        map[string]string
}

type WeightedBalancer

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

WeightedBalancer picks endpoints by configured weight.

func NewWeightedBalancer

func NewWeightedBalancer() *WeightedBalancer

func (*WeightedBalancer) AddModel

func (wb *WeightedBalancer) AddModel(model *models.ModelConfig)

func (*WeightedBalancer) Models

func (wb *WeightedBalancer) Models() []*models.ModelConfig

func (*WeightedBalancer) Next

func (*WeightedBalancer) RemoveModel

func (wb *WeightedBalancer) RemoveModel(modelName string)

func (*WeightedBalancer) Size

func (wb *WeightedBalancer) Size() int

Jump to

Keyboard shortcuts

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