QueryStrategy to allow querying routes based on Advertising Strategy

This commit is contained in:
Milos Gajdos
2020-01-16 12:48:36 +00:00
parent 689ae7cfc7
commit 5e85194a13
4 changed files with 146 additions and 18 deletions

View File

@@ -15,6 +15,8 @@ type QueryOptions struct {
Network string
// Router is router id
Router string
// Strategy is routing strategy
Strategy Strategy
}
// QueryService sets service to query
@@ -52,15 +54,23 @@ func QueryRouter(r string) QueryOption {
}
}
// QueryStrategy sets strategy to query
func QueryStrategy(s Strategy) QueryOption {
return func(o *QueryOptions) {
o.Strategy = s
}
}
// NewQuery creates new query and returns it
func NewQuery(opts ...QueryOption) QueryOptions {
// default options
qopts := QueryOptions{
Service: "*",
Address: "*",
Gateway: "*",
Network: "*",
Router: "*",
Service: "*",
Address: "*",
Gateway: "*",
Network: "*",
Router: "*",
Strategy: AdvertiseAll,
}
for _, o := range opts {