vpphelper

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2023 License: Apache-2.0 Imports: 14 Imported by: 1

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(newVppConfContents))

Note: newVppConfContents 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 = ""
)

Variables

This section is empty.

Functions

This section is empty.

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

Jump to

Keyboard shortcuts

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