socketclient

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 16 Imported by: 14

Documentation

Overview

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.

The current implementation only supports VPP binary API, the VPP stats API is not supported and clients still have to use vppapiclient for retrieving stats.

Requirements

The socketclient connects to unix domain socket defined in VPP configuration.

It is enabled by default at /run/vpp/api.sock by the following config section:

socksvr {
	socket-name default
}

If you want to use custom socket path:

socksvr {
	socket-name /run/vpp/api.sock
}

Index

Constants

View Source
const (
	// DefaultSocketName is default VPP API socket file path.
	DefaultSocketName = "/run/vpp/api.sock"
	// DefaultClientName is used for identifying client in socket registration
	DefaultClientName = "govppsock"
)

Variables

View Source
var (

	// DefaultConnectTimeout is default timeout for connecting
	DefaultConnectTimeout = time.Second * 3
	// DefaultDisconnectTimeout is default timeout for discconnecting
	DefaultDisconnectTimeout = time.Millisecond * 100
	// MaxWaitReady defines maximum duration of waiting for socket file
	MaxWaitReady = time.Second * 10
)

Functions

func SetLogger added in v0.4.0

func SetLogger(logger logrus.FieldLogger)

SetLogger sets global logger.

Types

type Client added in v0.4.0

type Client struct {
	// contains filtered or unexported fields
}

func NewVppClient

func NewVppClient(socket string) *Client

NewVppClient returns a new Client using socket. If socket is empty string DefaultSocketName is used.

func (*Client) Connect added in v0.4.0

func (c *Client) Connect() error

func (*Client) Disconnect added in v0.4.0

func (c *Client) Disconnect() error

func (*Client) GetMsgID added in v0.4.0

func (c *Client) GetMsgID(msgName string, msgCrc string) (uint16, error)

func (*Client) SendMsg added in v0.4.0

func (c *Client) SendMsg(context uint32, data []byte) error

func (*Client) SetClientName added in v0.4.0

func (c *Client) SetClientName(name string)

SetClientName sets a client name used for identification.

func (*Client) SetConnectTimeout added in v0.4.0

func (c *Client) SetConnectTimeout(t time.Duration)

SetConnectTimeout sets timeout used during connecting.

func (*Client) SetDisconnectTimeout added in v0.4.0

func (c *Client) SetDisconnectTimeout(t time.Duration)

SetDisconnectTimeout sets timeout used during disconnecting.

func (*Client) SetMsgCallback added in v0.4.0

func (c *Client) SetMsgCallback(cb adapter.MsgCallback)

func (*Client) WaitReady added in v0.4.0

func (c *Client) WaitReady() error

WaitReady checks socket file existence and waits for it if necessary

Jump to

Keyboard shortcuts

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