Code Review
/
govpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Merge "Mock Adapter: Switch back to handlers once the queue is empty."
[govpp.git]
/
api
/
api.go
diff --git
a/api/api.go
b/api/api.go
index
783f97a
..
c247417
100644
(file)
--- a/
api/api.go
+++ b/
api/api.go
@@
-28,11
+28,13
@@
const (
RequestMessage MessageType = iota
// ReplyMessage represents a VPP reply message
ReplyMessage
RequestMessage MessageType = iota
// ReplyMessage represents a VPP reply message
ReplyMessage
+ // EventMessage represents a VPP notification event message
+ EventMessage
// OtherMessage represents other VPP message (e.g. counters)
OtherMessage
)
// OtherMessage represents other VPP message (e.g. counters)
OtherMessage
)
-// Message is an interface that is implemented by all VPP Binary API messages generated by the binapi
_
generator.
+// 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
type Message interface {
// GetMessageName returns the original VPP name of the message, as defined in the VPP API.
GetMessageName() string
@@
-78,7
+80,8
@@
type MessageIdentifier interface {
// Channel is the main communication interface with govpp core. It contains two Go channels, one for sending the requests
// to VPP and one for receiving the replies from it. The user can access the Go channels directly, or use the helper
// Channel is the main communication interface with govpp core. It contains two Go channels, one for sending the requests
// to VPP and one for receiving the replies from it. The user can access the Go channels directly, or use the helper
-// methods provided inside of this package.
+// methods provided inside of this package. Do not use the same channel from multiple goroutines concurrently,
+// otherwise the responses could mix! Use multiple channels instead.
type Channel struct {
ReqChan chan *VppRequest // channel for sending the requests to VPP, closing this channel releases all resources in the ChannelProvider
ReplyChan chan *VppReply // channel where VPP replies are delivered to
type Channel struct {
ReqChan chan *VppRequest // channel for sending the requests to VPP, closing this channel releases all resources in the ChannelProvider
ReplyChan chan *VppReply // channel where VPP replies are delivered to
@@
-230,7
+233,8
@@
func (ch *Channel) receiveReplyInternal(msg Message) (LastReplyReceived bool, er
return false, err
}
if vppReply.MessageID != expMsgID {
return false, err
}
if vppReply.MessageID != expMsgID {
- err = fmt.Errorf("invalid message ID %d, expected %d", vppReply.MessageID, expMsgID)
+ err = fmt.Errorf("invalid message ID %d, expected %d "+
+ "(also check if multiple goroutines are not sharing one GoVPP channel)", vppReply.MessageID, expMsgID)
return false, err
}
// decode the message
return false, err
}
// decode the message