selector

package
v2.9.5 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultSelector is the default selector
	DefaultSelector = NewSelector()

	// ErrNoneAvailable is returned by select when no routes were provided to select from
	ErrNoneAvailable = errors.New("none available")
)

Functions

func Tests

func Tests(t *testing.T, s Selector)

Tests runs all the tests against a selector to ensure the implementations are consistent

Types

type Filter

type Filter func([]router.Route) []router.Route

Filter the routes

type Option

type Option func(*Options)

Option updates the options

type Options

type Options struct{}

Options used to configure a selector

type SelectOption

type SelectOption func(*SelectOptions)

SelectOption updates the select options

func WithFilter

func WithFilter(f Filter) SelectOption

WithFilter adds a filter to the options

type SelectOptions

type SelectOptions struct {
	Filters []Filter
}

SelectOptions used to configure selection

func NewSelectOptions

func NewSelectOptions(opts ...SelectOption) SelectOptions

NewSelectOptions parses select options

type Selector

type Selector interface {
	// Init a selector with options
	Init(...Option) error
	// Options the selector is using
	Options() Options
	// Select a route from the pool using the strategy
	Select([]router.Route, ...SelectOption) (*router.Route, error)
	// Record the error returned from a route to inform future selection
	Record(router.Route, error) error
	// Close the selector
	Close() error
	// String returns the name of the selector
	String() string
}

Selector selects a route from a pool

func NewSelector

func NewSelector(opts ...Option) Selector

NewSelector creates new selector and returns it

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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