selector

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MIT Imports: 3 Imported by: 2 modules, 6 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

Overview

Package selector defines generic interfaces for node selection with support for strategies, filters, and failure marking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filter

type Filter[T any] interface {
	Filter(context.Context, ...T) []T
}

Filter narrows a list of items to those that pass the filter criteria. Filters are applied before the selection strategy.

type Markable

type Markable interface {
	Marker() Marker
}

Markable exposes a Marker for health tracking. Nodes implement this so that selectors can temporarily skip failed nodes.

type Marker

type Marker interface {
	// Time returns the timestamp of the last failure.
	Time() time.Time
	// Count returns the number of consecutive failures.
	Count() int64
	// Mark records a failure.
	Mark()
	// Reset clears the failure state.
	Reset()
}

Marker tracks failure state for a selectable item. When a node fails, it is marked; the selection strategy can then deprioritize or skip marked nodes until they recover.

func NewFailMarker

func NewFailMarker() Marker

NewFailMarker creates a new Marker for tracking node failures.

type Selector

type Selector[T any] interface {
	Select(context.Context, ...T) T
}

Selector picks one item from a list using a configured strategy.

type Strategy

type Strategy[T any] interface {
	Apply(context.Context, ...T) T
}

Strategy applies a selection algorithm (e.g. round-robin, random, weighted) to choose one item from the list.

Jump to

Keyboard shortcuts

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