Documentation ¶
Overview ¶
Package endpoint provides some auxiliary functions about endpoint.
Index ¶
- func GetWeight(ep loadbalancer.Endpoint) int
- func Sort(eps loadbalancer.Endpoints)
- type Endpoint
- func (e *Endpoint) Concurrent() int
- func (e *Endpoint) Config() any
- func (e *Endpoint) ID() string
- func (e *Endpoint) Serve(c context.Context, r any) (any, error)
- func (e *Endpoint) ServeFunc() loadbalancer.ServeFunc
- func (e *Endpoint) SetConfig(c any)
- func (e *Endpoint) SetServeFunc(serve loadbalancer.ServeFunc)
- func (e *Endpoint) SetWeight(weight int)
- func (e *Endpoint) String() string
- func (e *Endpoint) Total() int
- func (e *Endpoint) Update(src loadbalancer.Endpoint) bool
- func (e *Endpoint) Weight() int
- type Unwrapper
- type Updater
- type Weighter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Endpoint ¶
type Endpoint struct {
// contains filtered or unexported fields
}
Endpoint is a common endpoint implementation.
func New ¶ added in v0.8.0
New returns a new common endpoint with the id and serve function.
If serve is nil, use a no-op function instead.
func (*Endpoint) Concurrent ¶ added in v0.8.0
Concurrent returns the number that the endpoint is serving the requests concurrently.
NOTICE: it's thread-safe.
func (*Endpoint) Config ¶ added in v0.8.0
Config returns the configuration information of the endpoint.
NOTICE: it's thread-safe.
func (*Endpoint) ID ¶
Serve returns the endpoint id, which implements the interface loadbalancer.Endpoint#ID.
func (*Endpoint) Serve ¶
Serve serves the request, which implements the interface loadbalancer.Endpoint#Serve.
func (*Endpoint) ServeFunc ¶ added in v0.8.0
func (e *Endpoint) ServeFunc() loadbalancer.ServeFunc
ServeFunc returns the serve function.
func (*Endpoint) SetConfig ¶ added in v0.8.0
SetConfig sets the configuration information of the endpoint.
NOTICE: it's thread-safe.
func (*Endpoint) SetServeFunc ¶ added in v0.8.0
func (e *Endpoint) SetServeFunc(serve loadbalancer.ServeFunc)
SetServeFunc resets the serve function of the endpoint.
func (*Endpoint) SetWeight ¶ added in v0.8.0
SetWeight resets the weight of the endpoint, which is thread-safe.
NOTICE: weight must be equal to or greater than 0. If 0, use 1 instead.
func (*Endpoint) String ¶ added in v0.8.0
String returns the description of the endpoint, which is equal to ID.
func (*Endpoint) Total ¶ added in v0.8.0
Total returns the total number that the endpoint has served the requests.
NOTICE: it's thread-safe.
type Unwrapper ¶ added in v0.8.0
type Unwrapper interface {
Unwrap() loadbalancer.Endpoint
}
Unwrapper is used to unwrap the inner endpoint.