2019-06-12 01:59:25 +03:00
|
|
|
// Package router provides an interface for micro network router
|
2019-06-06 18:37:40 +03:00
|
|
|
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 01:29:24 +03:00
|
|
|
// Table returns routing table
|
2019-06-07 15:29:09 +03:00
|
|
|
Table() Table
|
2019-06-12 01:59:25 +03:00
|
|
|
// Address returns router adddress
|
2019-06-07 01:29:24 +03:00
|
|
|
Address() string
|
2019-06-12 01:59:25 +03:00
|
|
|
// Network returns router network address
|
2019-06-07 19:20:22 +03:00
|
|
|
Network() string
|
2019-06-12 01:59:25 +03:00
|
|
|
// Start starts router
|
|
|
|
Start() error
|
|
|
|
// Stop stops router
|
|
|
|
Stop() error
|
|
|
|
// String returns router debug info
|
2019-06-06 18:37:40 +03:00
|
|
|
String() string
|
|
|
|
}
|
|
|
|
|
2019-06-07 15:29:09 +03:00
|
|
|
// RIB is Routing Information Base
|
|
|
|
type RIB interface {
|
|
|
|
// String returns debug info
|
|
|
|
String() string
|
|
|
|
}
|
|
|
|
|
2019-06-10 01:09:38 +03:00
|
|
|
// Option used by the router
|
2019-06-06 18:37:40 +03:00
|
|
|
type Option func(*Options)
|
|
|
|
|
2019-06-10 15:34:23 +03:00
|
|
|
// RouteOption is used to define routing table entry options
|
|
|
|
type RouteOption func(*RouteOptions)
|
2019-06-06 18:37:40 +03:00
|
|
|
|
2019-06-10 01:09:38 +03:00
|
|
|
// QueryOption is used to define query options
|
2019-06-07 01:29:24 +03:00
|
|
|
type QueryOption func(*QueryOptions)
|
2019-06-06 18:37:40 +03:00
|
|
|
|
2019-06-12 01:59:25 +03:00
|
|
|
// WatchOption is used to define what routes to watch in the table
|
|
|
|
type WatchOption func(*WatchOptions)
|
|
|
|
|
2019-06-06 18:37:40 +03:00
|
|
|
// NewRouter creates new Router and returns it
|
|
|
|
func NewRouter(opts ...Option) Router {
|
|
|
|
return newRouter(opts...)
|
|
|
|
}
|