diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2019-11-15 12:33:28 +0100 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2019-11-15 12:33:28 +0100 |
commit | e45d8802fd8de3602db630d75b370ff804000da9 (patch) | |
tree | 8803fe98338b4ed196d4c8881624c7ba869b9e53 /core/channel.go | |
parent | 2f75863ba9bff2d2f3488b70e441b5eefc91dfd2 (diff) |
Improve compatibility checking
- added CompatibilityError to api package to represent error with
list of incompatible messages
- added UnknownMsgError to adapter package to represent error for
unknown message
- added list of registered message types
Change-Id: I2623b45135521d52612ba91e4605fc064a7fc76e
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'core/channel.go')
-rw-r--r-- | core/channel.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/core/channel.go b/core/channel.go index 5b513e3..363a267 100644 --- a/core/channel.go +++ b/core/channel.go @@ -23,6 +23,7 @@ import ( "github.com/sirupsen/logrus" + "git.fd.io/govpp.git/adapter" "git.fd.io/govpp.git/api" ) @@ -144,14 +145,23 @@ func (ch *Channel) SendMultiRequest(msg api.Message) api.MultiRequestCtx { } func (ch *Channel) CheckCompatiblity(msgs ...api.Message) error { + var comperr api.CompatibilityError for _, msg := range msgs { - // TODO: collect all incompatible messages and return summarized error _, err := ch.msgIdentifier.GetMessageID(msg) if err != nil { + if uerr, ok := err.(*adapter.UnknownMsgError); ok { + m := fmt.Sprintf("%s_%s", uerr.MsgName, uerr.MsgCrc) + comperr.IncompatibleMessages = append(comperr.IncompatibleMessages, m) + continue + } + // other errors return immediatelly return err } } - return nil + if len(comperr.IncompatibleMessages) == 0 { + return nil + } + return &comperr } func (ch *Channel) SubscribeNotification(notifChan chan api.Message, event api.Message) (api.SubscriptionCtx, error) { |