diff options
author | Ondrej Fabry <ofabry@cisco.com> | 2020-07-17 10:36:28 +0200 |
---|---|---|
committer | Ondrej Fabry <ofabry@cisco.com> | 2020-07-17 11:43:41 +0200 |
commit | d1f24d37bd447b64e402298bb8eb2479681facf9 (patch) | |
tree | a3fc21ba730a91d8a402c7a5bf9c614e3677c4fc /examples/rpc-service/rpc_service.go | |
parent | 1548c7e12531e3d055567d761c580a1c7ff0ac40 (diff) |
Improve binapi generator
- simplified Size/Marshal/Unmarshal methods
- replace struc in unions with custom marshal/unmarshal
- fix imports in generated files
- fix mock adapter
- generate rpc service using low-level stream API (dumps generate control ping or stream msg..)
- move examples/binapi to binapi and generate all API for latest release
- add binapigen.Plugin for developing custom generator plugins
- optionally generate HTTP handlers (REST API) for RPC services
- add govpp program for browsing VPP API
Change-Id: I092e9ed2b0c17972b3476463c3d4b14dd76ed42b
Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
Diffstat (limited to 'examples/rpc-service/rpc_service.go')
-rw-r--r-- | examples/rpc-service/rpc_service.go | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/examples/rpc-service/rpc_service.go b/examples/rpc-service/rpc_service.go index 8ff6c08..e20e5c0 100644 --- a/examples/rpc-service/rpc_service.go +++ b/examples/rpc-service/rpc_service.go @@ -27,8 +27,8 @@ import ( "git.fd.io/govpp.git" "git.fd.io/govpp.git/adapter/socketclient" "git.fd.io/govpp.git/api" - "git.fd.io/govpp.git/examples/binapi/interfaces" - "git.fd.io/govpp.git/examples/binapi/vpe" + interfaces "git.fd.io/govpp.git/binapi/interface" + "git.fd.io/govpp.git/binapi/vpe" ) var ( @@ -47,20 +47,13 @@ func main() { } defer conn.Disconnect() - // create a channel - ch, err := conn.NewAPIChannel() - if err != nil { - log.Fatalln("ERROR: creating channel failed:", err) - } - defer ch.Close() - - showVersion(ch) - interfaceDump(ch) + showVersion(conn) + interfaceDump(conn) } // showVersion shows an example of simple request with services. -func showVersion(ch api.Channel) { - c := vpe.NewServiceClient(ch) +func showVersion(conn api.Connection) { + c := vpe.NewServiceClient(conn) version, err := c.ShowVersion(context.Background(), &vpe.ShowVersion{}) if err != nil { @@ -71,10 +64,10 @@ func showVersion(ch api.Channel) { } // interfaceDump shows an example of multi request with services. -func interfaceDump(ch api.Channel) { - c := interfaces.NewServiceClient(ch) +func interfaceDump(conn api.Connection) { + c := interfaces.NewServiceClient(conn) - stream, err := c.DumpSwInterface(context.Background(), &interfaces.SwInterfaceDump{}) + stream, err := c.SwInterfaceDump(context.Background(), &interfaces.SwInterfaceDump{}) if err != nil { log.Fatalln("ERROR: DumpSwInterface failed:", err) } |