Lots of refactoring. We now have basic routing table watcher.

This commit is contained in:
Milos Gajdos
2019-06-11 23:59:25 +01:00
parent 5899134b66
commit 338e0fdf18
7 changed files with 320 additions and 64 deletions

View File

@@ -1,4 +1,4 @@
// Package router provides an interface for micro network routers
// Package router provides an interface for micro network router
package router
// Router is micro network router
@@ -9,11 +9,15 @@ type Router interface {
Options() Options
// Table returns routing table
Table() Table
// Address returns router gossip adddress
// Address returns router adddress
Address() string
// Network returns micro network address
// Network returns router network address
Network() string
// String implemens fmt.Stringer interface
// Start starts router
Start() error
// Stop stops router
Stop() error
// String returns router debug info
String() string
}
@@ -32,6 +36,9 @@ type RouteOption func(*RouteOptions)
// QueryOption is used to define query options
type QueryOption func(*QueryOptions)
// WatchOption is used to define what routes to watch in the table
type WatchOption func(*WatchOptions)
// NewRouter creates new Router and returns it
func NewRouter(opts ...Option) Router {
return newRouter(opts...)