Documentation
¶
Overview ¶
Package gxfilter provides a interface for service filter
Package gxfilter provides a interface for service filter ¶
Package gxfilter provides a interface for service filter
Index ¶
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BalancerFunc ¶
type BalancerFunc func([]*gxregistry.Service) Balancer
func BalancerModeFunc ¶
func BalancerModeFunc(mode BalancerMode) BalancerFunc
type BalancerMode ¶
type BalancerMode int
BalancerMode defines the algorithm of selecting a provider from cluster
const ( SM_BEGIN BalancerMode = iota SM_Random SM_RoundRobin SM_Hash SM_END )
func (BalancerMode) String ¶
func (s BalancerMode) String() string
type Filter ¶
type Filter interface {
Options() Options
GetService(attr gxregistry.ServiceAttr) ([]*gxregistry.Service, error)
Filter(attr gxregistry.ServiceAttr) (Balancer, ServiceToken, error)
CheckTokenAlive(attr gxregistry.ServiceAttr, token ServiceToken) bool
Close() error
}
Filter used to get service nodes from registry.
type Option ¶
type Option func(*Options)
Option used to initialise the filter
func WithBalancerMode ¶
func WithBalancerMode(mode BalancerMode) Option
WithBalancerMode sets the default strategy for the filter
func WithContext ¶
func WithContext(ctx *gxcontext.ValuesContext) Option
func WithRegistry ¶
func WithRegistry(r gxregistry.Registry) Option
WithRegistry sets the registry used by the filter
type Options ¶
type Options struct {
Registry gxregistry.Registry
Mode BalancerMode // filter mode
Context *gxcontext.ValuesContext
}
type ServiceToken ¶
type ServiceToken = int64
Click to show internal directories.
Click to hide internal directories.