2019-06-06 17:37:40 +02:00
|
|
|
// Package router provides an interface for micro network routers
|
|
|
|
package router
|
|
|
|
|
|
|
|
// Router is micro network router
|
|
|
|
type Router interface {
|
|
|
|
// Initi initializes Router with options
|
|
|
|
Init(...Option) error
|
|
|
|
// Options returns Router options
|
|
|
|
Options() Options
|
2019-06-07 00:29:24 +02:00
|
|
|
// Table returns routing table
|
2019-06-07 14:29:09 +02:00
|
|
|
Table() Table
|
2019-06-10 20:50:54 +02:00
|
|
|
// Address returns router gossip adddress
|
2019-06-07 00:29:24 +02:00
|
|
|
Address() string
|
2019-06-10 20:50:54 +02:00
|
|
|
// Network returns micro network address
|
2019-06-07 18:20:22 +02:00
|
|
|
Network() string
|
2019-06-06 17:37:40 +02:00
|
|
|
// String implemens fmt.Stringer interface
|
|
|
|
String() string
|
|
|
|
}
|
|
|
|
|
2019-06-07 14:29:09 +02:00
|
|
|
// RIB is Routing Information Base
|
|
|
|
type RIB interface {
|
|
|
|
// String returns debug info
|
|
|
|
String() string
|
|
|
|
}
|
|
|
|
|
2019-06-10 00:09:38 +02:00
|
|
|
// Option used by the router
|
2019-06-06 17:37:40 +02:00
|
|
|
type Option func(*Options)
|
|
|
|
|
2019-06-10 14:34:23 +02:00
|
|
|
// RouteOption is used to define routing table entry options
|
|
|
|
type RouteOption func(*RouteOptions)
|
2019-06-06 17:37:40 +02:00
|
|
|
|
2019-06-10 00:09:38 +02:00
|
|
|
// QueryOption is used to define query options
|
2019-06-07 00:29:24 +02:00
|
|
|
type QueryOption func(*QueryOptions)
|
2019-06-06 17:37:40 +02:00
|
|
|
|
|
|
|
// NewRouter creates new Router and returns it
|
|
|
|
func NewRouter(opts ...Option) Router {
|
|
|
|
return newRouter(opts...)
|
|
|
|
}
|