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
- Variables
- func SetLogger(logger logrus.FieldLogger)
- type Client
- func (c *Client) Connect() error
- func (c *Client) Disconnect() error
- func (c *Client) GetMsgID(msgName string, msgCrc string) (uint16, error)
- func (c *Client) SendMsg(context uint32, data []byte) error
- func (c *Client) SetClientName(name string)
- func (c *Client) SetConnectTimeout(t time.Duration)
- func (c *Client) SetDisconnectTimeout(t time.Duration)
- func (c *Client) SetMsgCallback(cb adapter.MsgCallback)
- func (c *Client) WaitReady() error
Constants ¶
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 ¶
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 * 3 )
Functions ¶
func SetLogger ¶ added in v0.6.0
func SetLogger(logger logrus.FieldLogger)
SetLogger sets global logger.
Types ¶
type Client ¶ added in v0.6.0
type Client struct {
// contains filtered or unexported fields
}
func NewVppClient ¶
NewVppClient returns a new Client using socket. If socket is empty string DefaultSocketName is used.
func (*Client) Disconnect ¶ added in v0.6.0
func (*Client) SetClientName ¶ added in v0.6.0
SetClientName sets a client name used for identification.
func (*Client) SetConnectTimeout ¶ added in v0.6.0
SetConnectTimeout sets timeout used during connecting.
func (*Client) SetDisconnectTimeout ¶ added in v0.6.0
SetDisconnectTimeout sets timeout used during disconnecting.
func (*Client) SetMsgCallback ¶ added in v0.6.0
func (c *Client) SetMsgCallback(cb adapter.MsgCallback)
SetMsgCallback sets the callback for incoming messages.