common

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2019 License: BSD-3-Clause Imports: 6 Imported by: 2

Documentation

Overview

Package common is used for combining common functions from other packages which aren't connected with C language part

Index

Constants

View Source
const (
	// No - no output even after fatal errors
	No LogType = 1 << iota
	// Initialization - output during system initialization
	Initialization = 2
	// Debug - output during execution one time per time period (scheduler ticks)
	Debug = 4
	// Verbose - output during execution as soon as something happens. Can influence performance
	Verbose = 8
)

Variables

This section is empty.

Functions

func GetDPDKLogLevel

func GetDPDKLogLevel() string

GetDPDKLogLevel internal, used in flow package

func GetDefaultCPUs

func GetDefaultCPUs(cpuNumber int) []int

GetDefaultCPUs returns default core list {0, 1, ..., NumCPU}

func HandleCPUList

func HandleCPUList(s string, maxcpu int) ([]int, error)

HandleCPUs parses cpu list string into array of valid core numbers. Removes duplicates

func LogDebug

func LogDebug(logType LogType, v ...interface{})

LogDebug internal, used in all packages

func LogDrop

func LogDrop(logType LogType, v ...interface{})

LogDrop internal, used in all packages

func LogError

func LogError(logType LogType, v ...interface{}) string

LogError internal, used in all packages

func LogFatal

func LogFatal(logType LogType, v ...interface{})

LogFatal internal, used in all packages

func LogFatalf

func LogFatalf(logType LogType, format string, v ...interface{})

LogFatalf is a wrapper at LogFatal which makes formatting before logger.

func LogTitle

func LogTitle(logType LogType, v ...interface{})

LogTitle internal, used in all packages

func LogWarning

func LogWarning(logType LogType, v ...interface{})

LogWarning internal, used in all packages

func SetLogType

func SetLogType(logType LogType)

SetLogType internal, used in flow package

func WrapWithNFError

func WrapWithNFError(err error, message string, code ErrorCode) error

WrapWithNFError returns an error annotating err with a stack trace at the point WrapWithNFError is called, and the next our NFError. If err is nil, Wrap returns nil.

Types

type ErrorCode

type ErrorCode int

ErrorCode type for codes of errors

const (
	Fail ErrorCode
	ParseCPUListErr
	ReqTooManyPorts
	BadArgument
	UseNilFlowErr
	UseClosedFlowErr
	OpenedFlowAtTheEnd
	PortHasNoQueues
	NotAllQueuesUsed
	FailToInitPort
	ParseRuleJSONErr
	FileErr
	ParseRuleErr
	IncorrectArgInRules
	IncorrectRule
	AllocMbufErr
	PktMbufHeadRoomTooSmall
	NotEnoughCores
	CreatePortErr
	MaxCPUExceedErr
	PcapReadFail
	PcapWriteFail
	InvalidCPURangeErr
	SetAffinityErr
	MultipleReceivePort
	MultipleKNIPort
	WrongPort
	FailToInitDPDK
	FailToCreateKNI
	FailToReleaseKNI
	BadSocket
)

constants with error codes

func GetNFErrorCode

func GetNFErrorCode(err error) ErrorCode

GetNFErrorCode returns value of cCode field if err is NFError or pointer to it and -1 otherwise.

type LogType

type LogType uint8

LogType - type of logging, used in flow package

type NFError

type NFError struct {
	Code     ErrorCode
	Message  string
	CauseErr error
}

NFError is error type returned by nff-go functions

func GetNFError

func GetNFError(err error) (nferr *NFError)

GetNFError if error is NFerror or pointer to int returns pointer to NFError, otherwise returns nil.

func (*NFError) Cause

func (err *NFError) Cause() error

Cause returns the underlying cause of error, if possible. If not, returns err itself.

func (NFError) Error

func (err NFError) Error() string

Error method to implement error interface

func (*NFError) Format

func (err *NFError) Format(s fmt.State, verb rune)

Format makes formatted printing of errors, the following verbs are supported: %s, %v print the error. If the error has a Cause it will be printed recursively %+v - extended format. Each Frame of the error's StackTrace will be printed in detail if possible.

type RXTXStats added in v0.8.0

type RXTXStats struct {
	PacketsProcessed, PacketsDropped, BytesProcessed uint64
}

RXTXStats describes statistics for sender or receiver flow function node.

Jump to

Keyboard shortcuts

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