2020-07-19 12:51:04 +03:00
|
|
|
// Package selector is for node selection and load balancing
|
2023-04-11 22:20:37 +03:00
|
|
|
package selector // import "go.unistack.org/micro/v4/selector"
|
2020-06-30 16:54:38 +03: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 16:54:38 +03:00
|
|
|
|
|
|
|
// 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
|