selector

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2025 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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