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