micro/selector/selector.go

25 lines
708 B
Go
Raw Normal View History

2020-07-19 12:51:04 +03:00
// Package selector is for node selection and load balancing
package selector // import "go.unistack.org/micro/v4/selector"
import (
"errors"
)
// ErrNoneAvailable is returned by select when no routes were provided to select from
var ErrNoneAvailable = errors.New("none available")
// Selector selects a route from a pool
type Selector interface {
// Select a route from the pool using the strategy
Select([]string, ...SelectOption) (Next, error)
// Record the error returned from a route to inform future selection
Record(string, error) error
// Reset the selector
Reset() error
// String returns the name of the selector
String() string
}
// Next returns the next node
type Next func() string