Update router querying method (#834)

* Add address to router query options. Drop Query interface for QueryOptions

* Cleanup isMatch function

* Update network proto
This commit is contained in:
Asim Aslam
2019-10-09 17:13:52 +01:00
committed by GitHub
parent 107b7419b7
commit fe94237448
15 changed files with 249 additions and 122 deletions

View File

@@ -321,13 +321,15 @@ func (s *svc) Stop() error {
}
// Lookup looks up routes in the routing table and returns them
func (s *svc) Lookup(q router.Query) ([]router.Route, error) {
func (s *svc) Lookup(q ...router.QueryOption) ([]router.Route, error) {
// call the router
query := router.NewQuery(q...)
resp, err := s.router.Lookup(context.Background(), &pb.LookupRequest{
Query: &pb.Query{
Service: q.Options().Service,
Gateway: q.Options().Gateway,
Network: q.Options().Network,
Service: query.Service,
Gateway: query.Gateway,
Network: query.Network,
},
}, s.callOpts...)

View File

@@ -90,13 +90,15 @@ func (t *table) List() ([]router.Route, error) {
}
// Lookup looks up routes in the routing table and returns them
func (t *table) Query(q router.Query) ([]router.Route, error) {
func (t *table) Query(q ...router.QueryOption) ([]router.Route, error) {
query := router.NewQuery(q...)
// call the router
resp, err := t.table.Query(context.Background(), &pb.QueryRequest{
Query: &pb.Query{
Service: q.Options().Service,
Gateway: q.Options().Gateway,
Network: q.Options().Network,
Service: query.Service,
Gateway: query.Gateway,
Network: query.Network,
},
}, t.callOpts...)