balancer

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNotAvailable is returned when no upstream endpoint is available.
	ErrNotAvailable = errors.New("no available upstream at the moment")
)

Functions

func Register

func Register(names []string, h CreateBalancerHandler) error

Register registers a balancer handler under the given names.

Types

type Balancer

type Balancer interface {
	Select(ctx context.Context, hzCtx *app.RequestContext) (*target.Endpoint, error)
}

Balancer selects an endpoint from available upstream targets.

type CreateBalancerHandler

type CreateBalancerHandler func(endpoints []*target.Endpoint, params any) (Balancer, error)

CreateBalancerHandler is a function that creates a Balancer from endpoints and params.

func Factory

func Factory(name string) CreateBalancerHandler

Factory returns the registered balancer handler for the given name.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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