backend

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2016 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register added in v0.5.6

func Register(name string, ctor BackendCtor)

Types

type Backend

type Backend interface {
	// Called first to start the necessary event loops and such
	Run(ctx context.Context)
	// Called when the backend should create or begin managing a new network
	RegisterNetwork(ctx context.Context, network string, config *subnet.Config) (Network, error)
}

Besides the entry points in the Backend interface, the backend's New() function receives static network interface information (like internal and external IP addresses, MTU, etc) which it should cache for later use if needed.

To implement a singleton backend which manages multiple networks, the New() function should create the singleton backend object once, and return that object on on further calls to New(). The backend is guaranteed that the arguments passed via New() will not change across invocations. Also, since multiple RegisterNetwork() and Run() calls may be in-flight at any given time for a singleton backend, it must protect these calls with a mutex.

type BackendCtor added in v0.5.6

type BackendCtor func(sm subnet.Manager, ei *ExternalInterface) (Backend, error)

type ExternalInterface added in v0.5.6

type ExternalInterface struct {
	Iface     *net.Interface
	IfaceAddr net.IP
	ExtAddr   net.IP
}

type Manager added in v0.5.6

type Manager interface {
	GetBackend(backendType string) (Backend, error)
	Wait()
}

func NewManager added in v0.5.6

func NewManager(ctx context.Context, sm subnet.Manager, extIface *ExternalInterface) Manager

type Network added in v0.5.6

type Network interface {
	Lease() *subnet.Lease
	MTU() int
	Run(ctx context.Context)
}

type SimpleNetwork added in v0.5.6

type SimpleNetwork struct {
	SubnetLease *subnet.Lease
	ExtIface    *ExternalInterface
}

func (*SimpleNetwork) Lease added in v0.5.6

func (n *SimpleNetwork) Lease() *subnet.Lease

func (*SimpleNetwork) MTU added in v0.5.6

func (n *SimpleNetwork) MTU() int

func (*SimpleNetwork) Run added in v0.5.6

func (_ *SimpleNetwork) Run(ctx context.Context)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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