-// MessageType represents the type of a VPP message.
-// Note: this is currently derived from the message header (fields),
-// and in many cases it does not represent the actual type of VPP message.
-// This means that some replies can be identified as requests, etc.
-// TODO: use services to identify type of message
-type MessageType int
-
-const (
- // RequestMessage represents a VPP request message
- RequestMessage MessageType = iota
- // ReplyMessage represents a VPP reply message
- ReplyMessage
- // EventMessage represents a VPP event message
- EventMessage
- // OtherMessage represents other VPP message
- OtherMessage
-)
-
-// Message is an interface that is implemented by all VPP Binary API messages generated by the binapigenerator.
-type Message interface {
- // GetMessageName returns the original VPP name of the message, as defined in the VPP API.
- GetMessageName() string
-
- // GetCrcString returns the string with CRC checksum of the message definition (the string represents a hexadecimal number).
- GetCrcString() string
-
- // GetMessageType returns the type of the VPP message.
- GetMessageType() MessageType
+// Connection represents the client connection to VPP API.
+//
+// NOTE: This API is EXPERIMENTAL.
+type Connection interface {
+ // NewStream creates a new stream for sending and receiving messages.
+ // Context can be used to close the stream using cancel or timeout.
+ NewStream(ctx context.Context, options ...StreamOption) (Stream, error)
+
+ // Invoke can be used for a simple request-reply RPC.
+ // It creates stream and calls SendMsg with req and RecvMsg which returns
+ // reply.
+ Invoke(ctx context.Context, req Message, reply Message) error