policy

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Egress

type Egress[T any] interface {
	*T

	Alive() bool
}

Egress is a generic egress node used for balancing decisions.

type FirstReady

type FirstReady[PT Egress[T], T any] struct {
}

FirstReady returns first alive egress node starting from beginning. If no nodes are alive, it returns nil.

func NewFirstReady

func NewFirstReady[PT Egress[T], T any]() *FirstReady[PT, T]

func (*FirstReady[PT, T]) Get

func (fr *FirstReady[PT, T]) Get(egresses []PT) PT

type Random

type Random[PT Egress[T], T any] struct {
	*FirstReady[PT, T]
}

Random returns random egress node if it's alive. If chosen randomly node is not alive, it falls to FirstReady behaviour.

func NewRandom

func NewRandom[PT Egress[T], T any]() *Random[PT, T]

func (*Random[PT, T]) Get

func (rnd *Random[PT, T]) Get(egresses []PT) PT

type RoundRobin

type RoundRobin[PT Egress[T], T any] struct {
	// contains filtered or unexported fields
}

RoundRobin returns next alive egress node. It keeps track of previously chosen node index, so it can determine next one.

Node index is guarded by mutex.

func NewRoundRobin

func NewRoundRobin[PT Egress[T], T any]() *RoundRobin[PT, T]

func (*RoundRobin[PT, T]) Get

func (c *RoundRobin[PT, T]) Get(egresses []PT) PT

Jump to

Keyboard shortcuts

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