"strings"
"time"
- "git.fd.io/govpp.git/api"
"github.com/sirupsen/logrus"
+
+ "git.fd.io/govpp.git/api"
)
var (
return &multiRequestCtx{ch: ch, seqNum: seqNum}
}
-func getMsgFactory(msg api.Message) func() api.Message {
- return func() api.Message {
- return reflect.New(reflect.TypeOf(msg).Elem()).Interface().(api.Message)
+func (ch *Channel) CheckCompatiblity(msgs ...api.Message) error {
+ for _, msg := range msgs {
+ // TODO: collect all incompatible messages and return summarized error
+ _, err := ch.msgIdentifier.GetMessageID(msg)
+ if err != nil {
+ return err
+ }
}
+ return nil
}
func (ch *Channel) SubscribeNotification(notifChan chan api.Message, event api.Message) (api.SubscriptionCtx, error) {
}
func (ch *Channel) Close() {
- if ch.reqChan != nil {
- close(ch.reqChan)
- ch.reqChan = nil
- }
+ close(ch.reqChan)
}
func (req *requestCtx) ReceiveReply(msg api.Message) error {
case vppReply := <-ch.replyChan:
ignore, lastReplyReceived, err = ch.processReply(vppReply, expSeqNum, msg)
if ignore {
+ log.WithFields(logrus.Fields{
+ "expSeqNum": expSeqNum,
+ "channel": ch.id,
+ }).Warnf("ignoring received reply: %+v (expecting: %s)", vppReply, msg.GetMessageName())
continue
}
return lastReplyReceived, err
case <-timer.C:
+ log.WithFields(logrus.Fields{
+ "expSeqNum": expSeqNum,
+ "channel": ch.id,
+ }).Debugf("timeout (%v) waiting for reply: %s", ch.replyTimeout, msg.GetMessageName())
err = fmt.Errorf("no reply received within the timeout period %s", ch.replyTimeout)
return false, err
}
}
- return
}
func (ch *Channel) processReply(reply *vppReply, expSeqNum uint16, msg api.Message) (ignore bool, lastReplyReceived bool, err error) {
cmpSeqNums := compareSeqNumbers(reply.seqNum, expSeqNum)
if cmpSeqNums == -1 {
// reply received too late, ignore the message
- logrus.WithField("seqNum", reply.seqNum).Warn(
- "Received reply to an already closed binary API request")
+ log.WithField("seqNum", reply.seqNum).
+ Warn("Received reply to an already closed binary API request")
ignore = true
return
}