aboutsummaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorOndrej Fabry <ofabry@cisco.com>2020-06-16 10:40:34 +0200
committerOndrej Fabry <ofabry@cisco.com>2020-06-16 10:40:34 +0200
commit280b1c6c83b676ef4e592f4ecf60cb5b54b6a753 (patch)
treebf9a35f020de061ba66a432411ee44866405fe76 /api
parentf049390060630c0085fe4ad683c83a4a14a47ffb (diff)
Optimize socketclient adapter and add various code improvements
This commit includes: Features - optimized [socketclient](adapter/socketclient) adapter and add method to set client name - added list of compatible messages to `CompatibilityError` Fixes - `MsgCodec` will recover panic occurring during a message decoding - calling `Unsubscibe` will close the notification channel Other - improved log messages to provide more relevant info Examples - added more code samples of working with unions in [union example](examples/union-example) - added profiling mode to [perf bench](examples/perf-bench) example - improved [simple client](examples/simple-client) example to work properly even with multiple runs Dependencies - updated `github.com/sirupsen/logrus` dep to `v1.6.0` - updated `github.com/lunixbochs/struc` dep to `v0.0.0-20200521075829-a4cb8d33dbbe` Change-Id: I136a3968ccf9e93760d7ee2b9902fc7e6390a09d Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'api')
-rw-r--r--api/binapi.go33
1 files changed, 19 insertions, 14 deletions
diff --git a/api/binapi.go b/api/binapi.go
index d933612..96eb3bf 100644
--- a/api/binapi.go
+++ b/api/binapi.go
@@ -91,42 +91,47 @@ type Channel interface {
// It will return an error if any of the given messages are not compatible.
CheckCompatiblity(msgs ...Message) error
- // Close closes the API channel and releases all API channel-related resources in the ChannelProvider.
+ // Close closes the API channel and releases all API channel-related resources
+ // in the ChannelProvider.
Close()
}
// RequestCtx is helper interface which allows to receive reply on request.
type RequestCtx interface {
- // ReceiveReply receives a reply from VPP (blocks until a reply is delivered from VPP, or until an error occurs).
- // The reply will be decoded into the msg argument. Error will be returned if the response cannot be received or decoded.
+ // ReceiveReply receives a reply from VPP (blocks until a reply is delivered
+ // from VPP, or until an error occurs). The reply will be decoded into the msg
+ // argument. Error will be returned if the response cannot be received or decoded.
ReceiveReply(msg Message) error
}
// MultiRequestCtx is helper interface which allows to receive reply on multi-request.
type MultiRequestCtx interface {
- // ReceiveReply receives a reply from VPP (blocks until a reply is delivered from VPP, or until an error occurs).
- // The reply will be decoded into the msg argument. If the last reply has been already consumed, lastReplyReceived is
- // set to true. Do not use the message itself if lastReplyReceived is true - it won't be filled with actual data.
- // Error will be returned if the response cannot be received or decoded.
+ // ReceiveReply receives a reply from VPP (blocks until a reply is delivered
+ // from VPP, or until an error occurs).The reply will be decoded into the msg
+ // argument. If the last reply has been already consumed, lastReplyReceived is
+ // set to true. Do not use the message itself if lastReplyReceived is
+ // true - it won't be filled with actual data.Error will be returned if the
+ // response cannot be received or decoded.
ReceiveReply(msg Message) (lastReplyReceived bool, err error)
}
-// SubscriptionCtx is helper interface which allows to control subscription for notification events.
+// SubscriptionCtx is helper interface which allows to control subscription for
+// notification events.
type SubscriptionCtx interface {
- // Unsubscribe unsubscribes from receiving the notifications tied to the subscription context.
+ // Unsubscribe unsubscribes from receiving the notifications tied to the
+ // subscription context.
Unsubscribe() error
}
// CompatibilityError is the error type usually returned by CheckCompatibility
-// method of Channel. It describes all of the incompatible messages.
+// method of Channel. It contains list of all the compatible/incompatible messages.
type CompatibilityError struct {
- // IncompatibleMessages is the list of all messages
- // that failed compatibility check.
+ CompatibleMessages []string
IncompatibleMessages []string
}
func (c *CompatibilityError) Error() string {
- return fmt.Sprintf("%d incompatible messages: %v", len(c.IncompatibleMessages), c.IncompatibleMessages)
+ return fmt.Sprintf("%d/%d messages incompatible", len(c.IncompatibleMessages), len(c.CompatibleMessages)+len(c.IncompatibleMessages))
}
var (
@@ -155,6 +160,6 @@ func GetRegisteredMessageTypes() map[reflect.Type]string {
return registeredMessageTypes
}
-// GoVppAPIPackageIsVersion1 is referenced from generated binapi files
+// GoVppAPIPackageIsVersionX is referenced from generated binapi files
// to assert that that code is compatible with this version of the GoVPP api package.
const GoVppAPIPackageIsVersion1 = true