2019-07-08 18:51:55 +03:00
|
|
|
package table
|
2019-06-07 01:29:24 +03:00
|
|
|
|
2019-06-07 19:20:22 +03:00
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
)
|
2019-06-07 01:29:24 +03:00
|
|
|
|
|
|
|
var (
|
2019-06-13 14:09:49 +03:00
|
|
|
// ErrRouteNotFound is returned when no route was found in the routing table
|
2019-06-07 01:29:24 +03:00
|
|
|
ErrRouteNotFound = errors.New("route not found")
|
2019-06-13 14:09:49 +03:00
|
|
|
// ErrDuplicateRoute is returned when the route already exists
|
2019-06-07 15:29:09 +03:00
|
|
|
ErrDuplicateRoute = errors.New("duplicate route")
|
2019-06-07 01:29:24 +03:00
|
|
|
)
|
|
|
|
|
2019-06-13 14:09:49 +03:00
|
|
|
// Table defines routing table interface
|
2019-06-07 15:29:09 +03:00
|
|
|
type Table interface {
|
2019-07-10 19:46:22 +03:00
|
|
|
// Create new route in the routing table
|
|
|
|
Create(Route) error
|
2019-06-17 21:51:13 +03:00
|
|
|
// Delete deletes existing route from the routing table
|
|
|
|
Delete(Route) error
|
2019-06-13 14:09:49 +03:00
|
|
|
// Update updates route in the routing table
|
2019-06-13 00:30:42 +03:00
|
|
|
Update(Route) error
|
2019-06-19 20:01:48 +03:00
|
|
|
// List returns the list of all routes in the table
|
|
|
|
List() ([]Route, error)
|
2019-06-13 14:09:49 +03:00
|
|
|
// Lookup looks up routes in the routing table and returns them
|
2019-06-10 15:34:23 +03:00
|
|
|
Lookup(Query) ([]Route, error)
|
2019-06-13 14:09:49 +03:00
|
|
|
// Watch returns a watcher which allows to track updates to the routing table
|
2019-06-12 01:59:25 +03:00
|
|
|
Watch(opts ...WatchOption) (Watcher, error)
|
2019-06-13 14:09:49 +03:00
|
|
|
// Size returns the size of the routing table
|
2019-06-07 15:29:09 +03:00
|
|
|
Size() int
|
|
|
|
}
|
|
|
|
|
2019-07-17 02:06:11 +03:00
|
|
|
// Option used by the routing table
|
|
|
|
type Option func(*Options)
|
2019-06-07 01:29:24 +03:00
|
|
|
|
|
|
|
// NewTable creates new routing table and returns it
|
2019-07-17 02:06:11 +03:00
|
|
|
func NewTable(opts ...Option) Table {
|
2019-06-13 14:09:49 +03:00
|
|
|
return newTable(opts...)
|
2019-06-10 15:34:23 +03:00
|
|
|
}
|