vpphelper

package module
v0.0.0-...-e2b961f Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 14 Imported by: 9

README

vpphelper

vpphelper provides helper functions (using govpp) that helps to connect to VPP and configure VPP using a configuration (.conf) file.

StartAndDialContext function starts VPP using a VPP configuration file and returns a Connection to VPP.

conn, vppErrCh := vpphelper.StartAndDialContext(connectCtx)

The following two functional options can also be passed as parameters to the StartAndDialContext function:

  1. WithRootDir : sets the root directory for all .conf files
  2. WithVppConfig : sets vpp.conf file template. All the %[1]s in the template will be replaced by the rootDir.
conn, vppErrCh := vpphelper.StartAndDialContext(connectCtx, vpphelper.WithRootDir("/tmp/vpp2"), vpphelper.WithVppConfig(newDefaultVPPConfTemplate))

Note: newDefaultVPPConfTemplate variable in above code snippet is a multiline string having vpp.conf template. An example of such template is available in vpp.conf.go.

Documentation

Overview

Package vpphelper provides a simple Start function that will start up a local vpp, dial it, and return the grpc.ClientConnInterface

Index

Constants

View Source
const (
	// DefaultRootDir - Default value for RootDir
	DefaultRootDir = ""
)
View Source
const (

	// DefaultVPPConfTemplate - template for VPP config
	DefaultVPPConfTemplate = `` /* 5387-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func NewVPPConfigFile

func NewVPPConfigFile(configTemplate string, params VPPConfigParameters) string

NewVPPConfigFile creates new VPP config based on parameters

Types

type Connection

type Connection interface {
	api.Connection
	api.ChannelProvider
}

Connection Combination of api.Connection and api.ChannelProvider

func DialContext

func DialContext(ctx context.Context, filename string) Connection

DialContext - Dials vpp and returns a Connection DialContext is 'lazy' meaning that if there is no socket yet at filename, we will continue to try until there is one or the ctx is canceled.

func StartAndDialContext

func StartAndDialContext(ctx context.Context, opts ...Option) (conn Connection, errCh <-chan error)

StartAndDialContext - starts vpp Stdout and Stderr for vpp are set to be log.Entry(ctx).Writer().

type Option

type Option func(opt *option)

Option - Option for use with vppagent.Start(...)

func WithRootDir

func WithRootDir(rootDir string) Option

WithRootDir - set a root dir (usually a tmpDir) for all conf files.

func WithVppConfig

func WithVppConfig(vppConfig string) Option

WithVppConfig - vpp.conf template %[1]s will be replaced in the template with the value of the rootDir

type VPPConfigParameters

type VPPConfigParameters struct {
	DataSize int
	RootDir  string
}

VPPConfigParameters - custom parameters used by VPP config

Jump to

Keyboard shortcuts

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