adapter

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package adapter provides an interface between govpp core and the VPP. It is responsible for sending and receiving binary-encoded data to/from VPP via shared memory.

The default adapter being used for connection with real VPP is called vppapiclient. It is based on the communication with the vppapiclient VPP library written in C via CGO.

Apart from the vppapiclient adapter, mock adapter is provided for unit/integration testing where the actual communication with VPP is not demanded.

Index

Constants

View Source
const (
	// DefaultBinapiSocket defines a default socket file path for VPP binary API.
	DefaultBinapiSocket = "/run/vpp/api.sock"
)
View Source
const (
	// DefaultStatsSocket defines a default socket file path for VPP stats API.
	DefaultStatsSocket = "/run/vpp/stats.sock"
)

Variables

View Source
var (
	ErrStatsDataBusy     = errors.New("stats data busy")
	ErrStatsDirStale     = errors.New("stats dir stale")
	ErrStatsDisconnected = errors.New("stats disconnected")
	ErrStatsAccessFailed = errors.New("stats access failed")
)
View Source
var (
	// ErrNotImplemented is an error returned when missing implementation.
	ErrNotImplemented = errors.New("not implemented for this OS")
)

Functions

func ReduceCombinedCounterStatIndex

func ReduceCombinedCounterStatIndex(s CombinedCounterStat, i int) [2]uint64

ReduceCombinedCounterStatIndex returns reduced CombinedCounterStat s for index i.

func ReduceSimpleCounterStatIndex

func ReduceSimpleCounterStatIndex(s SimpleCounterStat, i int) uint64

ReduceSimpleCounterStatIndex returns reduced SimpleCounterStat s for index i.

Types

type CombinedCounter

type CombinedCounter [2]uint64

CombinedCounter represents counter with two values, for packet count and bytes count.

func (CombinedCounter) Bytes

func (s CombinedCounter) Bytes() uint64

func (CombinedCounter) Packets

func (s CombinedCounter) Packets() uint64

type CombinedCounterStat

type CombinedCounterStat [][]CombinedCounter

CombinedCounterStat represents indexed stat for CombinedCounterVector. The outer array represents workers and the inner array represents interface/node/.. indexes. Values should be aggregated per interface/node for every worker. ReduceCombinedCounterStatIndex can be used to reduce specific index.

func (CombinedCounterStat) IsZero

func (s CombinedCounterStat) IsZero() bool

func (CombinedCounterStat) Type

func (s CombinedCounterStat) Type() StatType

type Counter

type Counter uint64

Counter represents simple counter with single value, which is usually packet count.

type EmptyStat

type EmptyStat string

EmptyStat represents removed counter directory

func (EmptyStat) IsZero

func (s EmptyStat) IsZero() bool

func (EmptyStat) Type

func (s EmptyStat) Type() StatType

type ErrorStat

type ErrorStat []Counter

ErrorStat represents stat for ErrorIndex. The array represents workers.

func (ErrorStat) IsZero

func (s ErrorStat) IsZero() bool

func (ErrorStat) Type

func (s ErrorStat) Type() StatType

type MsgCallback

type MsgCallback func(msgID uint16, data []byte)

MsgCallback defines func signature for message callback.

type Name

type Name []byte

Name represents string value stored under name vector.

func (Name) String

func (n Name) String() string

type NameStat

type NameStat []Name

NameStat represents stat for NameVector.

func (NameStat) IsZero

func (s NameStat) IsZero() bool

func (NameStat) Type

func (s NameStat) Type() StatType

type ScalarStat

type ScalarStat float64

ScalarStat represents stat for ScalarIndex.

func (ScalarStat) IsZero

func (s ScalarStat) IsZero() bool

func (ScalarStat) Type

func (s ScalarStat) Type() StatType

type SimpleCounterStat

type SimpleCounterStat [][]Counter

SimpleCounterStat represents indexed stat for SimpleCounterVector. The outer array represents workers and the inner array represents interface/node/.. indexes. Values should be aggregated per interface/node for every worker. ReduceSimpleCounterStatIndex can be used to reduce specific index.

func (SimpleCounterStat) IsZero

func (s SimpleCounterStat) IsZero() bool

func (SimpleCounterStat) Type

func (s SimpleCounterStat) Type() StatType

type Stat

type Stat interface {
	// IsZero returns true if all of its values equal to zero.
	IsZero() bool

	// Type returns underlying type of a stat
	Type() StatType
	// contains filtered or unexported methods
}

Stat represents some type of stat which is usually defined by StatType.

type StatDir

type StatDir struct {
	Epoch   int64
	Entries []StatEntry
}

StatDir defines directory of stats entries created by PrepareDir.

type StatEntry

type StatEntry struct {
	StatIdentifier
	Type    StatType
	Data    Stat
	Symlink bool
}

StatEntry represents single stat entry. The type of stat stored in Data is defined by Type.

type StatIdentifier

type StatIdentifier struct {
	Index uint32
	Name  []byte
}

StatIdentifier holds a stat entry name and index

type StatType

type StatType string

StatType represents type of stat directory and simply defines what type of stat data is stored in the stat entry.

const (
	Unknown               StatType = "UnknownStatType"
	ScalarIndex           StatType = "ScalarIndex"
	SimpleCounterVector   StatType = "SimpleCounterVector"
	CombinedCounterVector StatType = "CombinedCounterVector"
	ErrorIndex            StatType = "ErrorIndex"
	NameVector            StatType = "NameVector"
	Empty                 StatType = "Empty"
	Symlink               StatType = "Symlink"
)

type StatsAPI

type StatsAPI interface {
	// Connect establishes client connection to the stats API.
	Connect() error
	// Disconnect terminates client connection.
	Disconnect() error

	// ListStats lists indexed names for stats matching patterns.
	ListStats(patterns ...string) (indexes []StatIdentifier, err error)
	// DumpStats dumps all stat entries.
	DumpStats(patterns ...string) (entries []StatEntry, err error)

	// PrepareDir prepares new stat dir for entries that match any of prefixes.
	PrepareDir(patterns ...string) (*StatDir, error)
	// PrepareDirOnIndex prepares new stat dir for entries that match any of indexes.
	PrepareDirOnIndex(indexes ...uint32) (*StatDir, error)
	// UpdateDir updates stat dir and all of their entries.
	UpdateDir(dir *StatDir) error
}

StatsAPI provides connection to VPP stats API.

type UnknownMsgError

type UnknownMsgError struct {
	MsgName string
	MsgCrc  string
}

UnknownMsgError is the error type usually returned by GetMsgID method of VppAPI. It describes the name and CRC for the unknown message.

func (*UnknownMsgError) Error

func (u *UnknownMsgError) Error() string

type VppAPI

type VppAPI interface {
	// Connect connects the process to VPP.
	Connect() error

	// Disconnect disconnects the process from VPP.
	Disconnect() error

	// GetMsgID returns a runtime message ID for the given message name and CRC.
	GetMsgID(msgName string, msgCrc string) (msgID uint16, err error)

	// SendMsg sends a binary-encoded message to VPP.
	SendMsg(context uint32, data []byte) error

	// SetMsgCallback sets a callback function that will be called by the adapter whenever a message comes from VPP.
	SetMsgCallback(cb MsgCallback)

	// WaitReady waits until adapter is ready.
	WaitReady() error
}

VppAPI provides connection to VPP binary API. It is responsible for sending and receiving of binary-encoded messages to/from VPP.

Directories

Path Synopsis
Package mock is an alternative VPP adapter aimed for unit/integration testing where the actual communication with VPP is not demanded.
Package mock is an alternative VPP adapter aimed for unit/integration testing where the actual communication with VPP is not demanded.
binapi
Package binapi is a helper package for generic handling of VPP binary API messages in the mock adapter and integration tests.
Package binapi is a helper package for generic handling of VPP binary API messages in the mock adapter and integration tests.
Package socketclient is a pure Go implementation of adapter.VppAPI, which uses unix domain sockets as the transport for connecting to the VPP binary API.
Package socketclient is a pure Go implementation of adapter.VppAPI, which uses unix domain sockets as the transport for connecting to the VPP binary API.
Package statsclient is pure Go implementation of VPP stats API client.
Package statsclient is pure Go implementation of VPP stats API client.

Jump to

Keyboard shortcuts

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