fwdcontext

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package fwdcontext contains routines for managing the context of the forwarding engine.

Index

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

func New(id, instance string) *Context

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

func (ctx *Context) Cleanup(ch chan bool, isPort func(*fwdpb.ObjectId) bool)

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

func (ctx *Context) GetNotificationQueue() *queue.Queue

GetNotificationQueue returns a pointer to the queue of notifications in the context.

func (*Context) Notify

func (ctx *Context) Notify(event *fwdpb.EventDesc) error

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

func (ctx *Context) SetNotificationQueue(val *queue.Queue, address string)

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.

func (*Context) String

func (ctx *Context) String() string

String returns a formatted string representing the context.

type NotificationCallback

type NotificationCallback func(*fwdpb.EventDesc)

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.

Jump to

Keyboard shortcuts

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