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