routemanager

package
v0.0.0-...-0f8bab2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//NotFoundError route not found error
	ErrNotFound = errors.New("Route could not found")
)

Functions

This section is empty.

Types

type Route

type Route struct {
	Dst   net.IPNet
	Gw    net.IP
	Table int
}

Route structure represents just-enough data to manage IP routes from user code

type RouteManager

type RouteManager interface {
	//IsRegistered returns true if a Route (by it's name) is already managed
	IsRegistered(string) bool
	//RegisterRoute creates and start watching the route. If the route is deleted after the registration, RouteWatchers will be notified.
	RegisterRoute(string, Route) error
	//DeRegisterRoute removed the route from the kernel and also stop watching it.
	DeRegisterRoute(string) error
	//RegisterWatcher registers a new RouteWatcher, which will be notified if the managed routes are deleted.
	RegisterWatcher(RouteWatcher)
	//DeRegisterWatcher removes watchers
	DeRegisterWatcher(RouteWatcher)
	//Run is the main event loop, shall run in it's own go-routine. Returns when the channel sent in got closed.
	Run(chan struct{}) error
}

RouteManager is the main interface, which is implemented by the package

func New

func New() RouteManager

New creates a RouteManager for production use. It populates the routeManagerImpl structure with the final pointers to netlink package's functions.

type RouteWatcher

type RouteWatcher interface {
	RouteDeleted(Route)
}

RouteWatcher is a user-implemented interface, where RouteManager will call back if a managed route is damaged

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL