selector: add filters to replace depricated client/selector filters (#1785)

This commit is contained in:
ben-toogood
2020-07-02 16:09:48 +01:00
committed by GitHub
parent d577dd6abe
commit 6898a65508
7 changed files with 86 additions and 91 deletions

View File

@@ -38,7 +38,15 @@ func (r *roundrobin) Options() selector.Options {
return selector.Options{}
}
func (r *roundrobin) Select(routes []router.Route) (*router.Route, error) {
func (r *roundrobin) Select(routes []router.Route, opts ...selector.SelectOption) (*router.Route, error) {
// parse the options
options := selector.NewSelectOptions(opts...)
// apply the filters
for _, f := range options.Filters {
routes = f(routes)
}
if len(routes) == 0 {
return nil, selector.ErrNoneAvailable
}