Change SelectFilter to Filter
This commit is contained in:
parent
a4c05fd6ad
commit
4d4f842702
@ -41,7 +41,7 @@ func (dc *dcWrapper) Call(ctx context.Context, req client.Request, rsp interface
|
|||||||
}
|
}
|
||||||
|
|
||||||
callOptions := append(opts, client.WithSelectOption(
|
callOptions := append(opts, client.WithSelectOption(
|
||||||
selector.Filter(filter),
|
selector.WithFilter(filter),
|
||||||
))
|
))
|
||||||
|
|
||||||
fmt.Printf("[DC Wrapper] filtering for datacenter %s\n", md["datacenter"])
|
fmt.Printf("[DC Wrapper] filtering for datacenter %s\n", md["datacenter"])
|
||||||
|
@ -15,7 +15,7 @@ type Options struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type SelectOptions struct {
|
type SelectOptions struct {
|
||||||
Filters []SelectFilter
|
Filters []Filter
|
||||||
|
|
||||||
// Other options for implementations of the interface
|
// Other options for implementations of the interface
|
||||||
// can be stored in a context
|
// can be stored in a context
|
||||||
@ -35,9 +35,9 @@ func Registry(r registry.Registry) Option {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Filter adds a filter function to the list of filters
|
// WithFilter adds a filter function to the list of filters
|
||||||
// used during the Select call.
|
// used during the Select call.
|
||||||
func Filter(fn SelectFilter) SelectOption {
|
func WithFilter(fn Filter) SelectOption {
|
||||||
return func(o *SelectOptions) {
|
return func(o *SelectOptions) {
|
||||||
o.Filters = append(o.Filters, fn)
|
o.Filters = append(o.Filters, fn)
|
||||||
}
|
}
|
||||||
|
@ -82,8 +82,8 @@ type Selector interface {
|
|||||||
// based on the selector's algorithm
|
// based on the selector's algorithm
|
||||||
type Next func() (*registry.Node, error)
|
type Next func() (*registry.Node, error)
|
||||||
|
|
||||||
// SelectFilter is used to filter a service during the selection process
|
// Filter is used to filter a service during the selection process
|
||||||
type SelectFilter func([]*registry.Service) []*registry.Service
|
type Filter func([]*registry.Service) []*registry.Service
|
||||||
|
|
||||||
var (
|
var (
|
||||||
DefaultSelector = newRandomSelector()
|
DefaultSelector = newRandomSelector()
|
||||||
|
Loading…
Reference in New Issue
Block a user