You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
698 B

2 years ago
package selector
import (
"context"
)
11 months ago
var ErrNoAvailable = errorx.ServiceUnavailable("no_available_node", "")
2 years ago
type Selector interface {
Rebalancer
Select(ctx context.Context, opts ...SelectOption) (selected Node, done DoneFunc, err error)
2 years ago
}
type Rebalancer interface {
Apply(nodes []Node)
}
type Builder interface {
Build() Selector
}
type Node interface {
Scheme() string
Address() string
ServiceName() string
2 years ago
InitialWeight() *int64
Version() string
Metadata() map[string]string
}
type DoneInfo struct {
Err error
ReplyMD ReplyMD
2 years ago
BytesSent bool
BytesReceived bool
}
type ReplyMD interface {
Get(key string) string
}
type DoneFunc func(ctx context.Context, di DoneInfo)