RPC services #58
ondrej-fabry
announced in
Design
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This discussion contains info about the RPC services - the code generated for the RPC services specified by the VPP API.
Table of Contents
💠 RPC Services
RPC Services are specified for VPP API packages (in the
*.api.json
files) and are defined as list of RPC methods, where the RPC method is defined as a request message type used to call it, expected message type of the response(s), message type of the events it enable/disables and possibly other attributes related to the RPC method. This information is used to generate extra file containing: an interface type for the RPC service and client implementation for this interface where each client method is implemented according to the RPC service specification.The generated code for RPC services made it possible to get rid of the boilerplate and allow users to use simple methods of an interface for calling VPP API instead of manually sending/receiving the right request message types. The generated code includes an implementation of the RPC client which uses the new Stream API to send/receive messages of type declared by RPC service.
🔹 Features
The generated code currently contains the following features:
context.Context
value as the first parameter, which greatly enhances tracing capabilities or pass any request-scoped data from the callerRetval
field for replies, returning an error in case it's non-zeroControlPing
request after classic dump requests (dump+ping = details..+ping_reply)this allows backwards compatibility with binapi generated for older VPP
🔹 Background
With the new Stream API, being so low-level, users would have to do much of the things done by Channels before themselves; e.g. send
ControlPings
after each dump manually. For this reasons we also introduced generated RPC methods, where each generate binapi package came with a service interface and also client implementation of this interface where all of the boilerplate was automatically generated.BEFORE: Using
Channel
to manually send/receive messagesHere is a code example of using the
Channel
to manually send requests and receive replies:NOW: Using the generated
RPCService
to call service methodsHere is a code example of using the generated
RPCService
interface to call service RPC methods:Beta Was this translation helpful? Give feedback.
All reactions