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
- Variables
- func ReduceCombinedCounterStatIndex(s CombinedCounterStat, i int) [2]uint64
- func ReduceSimpleCounterStatIndex(s SimpleCounterStat, i int) uint64
- type CombinedCounter
- type CombinedCounterStat
- type Counter
- type EmptyStat
- type ErrorStat
- type MsgCallback
- type Name
- type NameStat
- type ScalarStat
- type SimpleCounterStat
- type Stat
- type StatDir
- type StatEntry
- type StatIdentifier
- type StatType
- type StatsAPI
- type UnknownMsgError
- type VppAPI
Constants ¶
const (
// DefaultBinapiSocket defines a default socket file path for VPP binary API.
DefaultBinapiSocket = "/run/vpp/api.sock"
)
const (
// DefaultStatsSocket defines a default socket file path for VPP stats API.
DefaultStatsSocket = "/run/vpp/stats.sock"
)
Variables ¶
var ( ErrStatsDataBusy = errors.New("stats data busy") ErrStatsDirStale = errors.New("stats dir stale") ErrStatsDisconnected = errors.New("stats disconnected") ErrStatsAccessFailed = errors.New("stats access failed") )
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 ErrorStat ¶
type ErrorStat []Counter
ErrorStat represents stat for ErrorIndex. The array represents workers.
type MsgCallback ¶
MsgCallback defines func signature for message callback.
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 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 ¶
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 ¶
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. |