selector

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultMaxFails    = 1
	DefaultFailTimeout = 10 * time.Second
)

default options for FailFilter

Variables

This section is empty.

Functions

func BackupFilter

func BackupFilter[T any]() selector.Filter[T]

BackupFilter filters the backup objects. An object is marked as backup if its metadata has backup flag.

func FIFOStrategy

func FIFOStrategy[T any]() selector.Strategy[T]

FIFOStrategy is a strategy for node selector. The node will be selected from first to last, and will stick to the selected node until it is failed.

func FailFilter

func FailFilter[T any](maxFails int, timeout time.Duration) selector.Filter[T]

FailFilter filters the dead objects. An object is marked as dead if its failed count is greater than MaxFails.

func HashStrategy

func HashStrategy[T any]() selector.Strategy[T]

func NewSelector

func NewSelector[T any](strategy selector.Strategy[T], filters ...selector.Filter[T]) selector.Selector[T]

func RandomStrategy

func RandomStrategy[T any]() selector.Strategy[T]

RandomStrategy is a strategy for node selector. The node will be selected randomly.

func RoundRobinStrategy

func RoundRobinStrategy[T any]() selector.Strategy[T]

RoundRobinStrategy is a strategy for node selector. The node will be selected by round-robin algorithm.

Types

type RandomWeighted

type RandomWeighted[T any] struct {
	// contains filtered or unexported fields
}

func NewRandomWeighted

func NewRandomWeighted[T any]() *RandomWeighted[T]

func (*RandomWeighted[T]) Add

func (rw *RandomWeighted[T]) Add(item T, weight int)

func (*RandomWeighted[T]) Next

func (rw *RandomWeighted[T]) Next() (v T)

func (*RandomWeighted[T]) Reset

func (rw *RandomWeighted[T]) Reset()

Jump to

Keyboard shortcuts

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