From 459f4c83872d6be1c8a792f22f0f8aa8340888ae Mon Sep 17 00:00:00 2001 From: Milos Gajdos Date: Sun, 9 Jun 2019 23:19:56 +0100 Subject: [PATCH] Added Router ID and query options to limit number of results --- router/default.go | 5 ++++- router/query.go | 9 +++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/router/default.go b/router/default.go index 64770ce9..8e1b1e94 100644 --- a/router/default.go +++ b/router/default.go @@ -88,7 +88,10 @@ func (r *router) Address() string { func (r *router) String() string { sb := &strings.Builder{} - s := fmt.Sprintf("Router Local Address: %s\n", r.opts.Address) + s := fmt.Sprintf("Router ID: %s\n", r.id.String()) + sb.WriteString(s) + + s = fmt.Sprintf("Router Local Address: %s\n", r.opts.Address) sb.WriteString(s) s = fmt.Sprintf("Router Network Address: %s\n", r.opts.Network) diff --git a/router/query.go b/router/query.go index 9632e062..677e2575 100644 --- a/router/query.go +++ b/router/query.go @@ -18,6 +18,8 @@ type QueryOptions struct { Service string // Policy defines query lookup policy Policy LookupPolicy + // Count defines max number of results to return + Count int } // EntryOpts allows to set the route query options @@ -41,6 +43,13 @@ func QueryLookupPolicy(p LookupPolicy) QueryOption { } } +// ResultCount allows to set max results to return +func ResultCount(c int) QueryOption { + return func(o *QueryOptions) { + o.Count = c + } +} + // Query defines routing table query type Query interface { // Options returns query options