Documentation ¶
Overview ¶
Package fwdcontext contains routines for managing the context of the forwarding engine.
Index ¶
- type Context
- func (ctx *Context) Cleanup(ch chan bool, isPort func(*fwdpb.ObjectId) bool)
- func (ctx *Context) GetNotificationQueue() *queue.Queue
- func (ctx *Context) Notify(event *fwdpb.EventDesc) error
- func (ctx *Context) PacketSink() PacketCallback
- func (ctx *Context) SetNotification(call NotificationCallback, address string) error
- func (ctx *Context) SetNotificationQueue(val *queue.Queue, address string)
- func (ctx *Context) SetPacketSink(call PacketCallback, address string) error
- func (ctx *Context) String() string
- type NotificationCallback
- type PacketCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { sync.RWMutex // Synchronization between provisioning and forwarding Objects *fwdobject.Table // Set of all visible forwarding objects ID string // ID of the context Instance string // Name of the forwarding engine instance PacketAddress string // Address of the packet service in host:port format NotificationAddress string // Address of the notification service in host:port format Attributes fwdattribute.Set // contains filtered or unexported fields }
A Context encapsulates the state of an instance of the forwarding engine.
A context is the domain for synchronization. There are two users of context; provisioning and packet processing. Provisioning takes a rw lock on the context, and modifies objects within the context. Packet processing takes a read-lock on the context to process packets. Since provisioning and packet processing directly manipulate objects within the context, they must explicitly take the appropriate lock.
The context provides mechanisms to send notifications (notify) and packets (punt). Notify is non-blocking and sends notifications via an unbounded queue. Punt is a blocking call, and the caller is responsible for ordering and blocking guarantees.
func New ¶
New creates a new forwarding context with the specified id and fwd engine name. The id identifies the forwarding context in an forwarding engine instance, and the instance identifies the forwarding engine instance in the universe.
func (*Context) Cleanup ¶
Cleanup cleans up the context. It first cleans up the objects that satisfy isPort. Then it unblocks the caller by sending a message on the channel. Then it cleans up the rest of the objects.
func (*Context) GetNotificationQueue ¶
GetNotificationQueue returns a pointer to the queue of notifications in the context.
func (*Context) Notify ¶
Notify enqueues a notification request if there is a notification service. This is a non-blocking call.
func (*Context) PacketSink ¶
func (ctx *Context) PacketSink() PacketCallback
PacketSink returns a handler to the packet sink service.
func (*Context) SetNotification ¶
func (ctx *Context) SetNotification(call NotificationCallback, address string) error
SetNotification sets the notification service for the context. If the notification service is set to nil, notifications are disabled for the context.
func (*Context) SetNotificationQueue ¶
SetNotificationQueue sets the notification queue.
func (*Context) SetPacketSink ¶
func (ctx *Context) SetPacketSink(call PacketCallback, address string) error
SetPacketSink sets the packet sink service for the context. If the packet sink service is not set to nil, packets are dropped.
type NotificationCallback ¶
An NotificationCallback generates events to a notification service.
type PacketCallback ¶
type PacketCallback func(*fwdpb.PacketInjectRequest) (*fwdpb.PacketInjectReply, error)
A PacketCallback transmits packets to a packet sink as specified by the injection request.