Documentation ¶
Index ¶
- Constants
- func BackupFilter[T any]() selector.Filter[T]
- func FIFOStrategy[T any]() selector.Strategy[T]
- func FailFilter[T any](maxFails int, timeout time.Duration) selector.Filter[T]
- func HashStrategy[T any]() selector.Strategy[T]
- func NewSelector[T any](strategy selector.Strategy[T], filters ...selector.Filter[T]) selector.Selector[T]
- func RandomStrategy[T any]() selector.Strategy[T]
- func RoundRobinStrategy[T any]() selector.Strategy[T]
- type RandomWeighted
Constants ¶
View Source
const ( DefaultMaxFails = 1 DefaultFailTimeout = 10 * time.Second )
default options for FailFilter
Variables ¶
This section is empty.
Functions ¶
func BackupFilter ¶
BackupFilter filters the backup objects. An object is marked as backup if its metadata has backup flag.
func FIFOStrategy ¶
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 ¶
FailFilter filters the dead objects. An object is marked as dead if its failed count is greater than MaxFails.
func HashStrategy ¶
func NewSelector ¶
func RandomStrategy ¶
RandomStrategy is a strategy for node selector. The node will be selected randomly.
func RoundRobinStrategy ¶
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()
Click to show internal directories.
Click to hide internal directories.