Strip Advertise/Process from router

This commit is contained in:
Asim Aslam
2020-08-14 23:51:52 +01:00
parent 5238a8a85f
commit 55d62fc1a5
10 changed files with 129 additions and 696 deletions

View File

@@ -4,6 +4,7 @@ package router
type QueryOption func(*QueryOptions)
// QueryOptions are routing table query options
// TODO replace with Filter(Route) bool
type QueryOptions struct {
// Service is destination service name
Service string
@@ -15,8 +16,8 @@ type QueryOptions struct {
Network string
// Router is router id
Router string
// Strategy is routing strategy
Strategy Strategy
// Link to query
Link string
}
// QueryService sets service to query
@@ -54,10 +55,10 @@ func QueryRouter(r string) QueryOption {
}
}
// QueryStrategy sets strategy to query
func QueryStrategy(s Strategy) QueryOption {
// QueryLink sets the link to query
func QueryLink(link string) QueryOption {
return func(o *QueryOptions) {
o.Strategy = s
o.Link = link
}
}
@@ -65,12 +66,12 @@ func QueryStrategy(s Strategy) QueryOption {
func NewQuery(opts ...QueryOption) QueryOptions {
// default options
qopts := QueryOptions{
Service: "*",
Address: "*",
Gateway: "*",
Network: "*",
Router: "*",
Strategy: AdvertiseAll,
Service: "*",
Address: "*",
Gateway: "*",
Network: "*",
Router: "*",
Link: DefaultLink,
}
for _, o := range opts {