X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=examples%2Frpc-service%2Frpc_service.go;h=e20e5c074be2e181a831e8bb85b48738494a8cf0;hb=5de7f6b85458615fa592a335d45c546397f32c9a;hp=ca0c295e99af350db8d74aeee056a34beeca5b57;hpb=ef471318d66dd2832df4dc929d312f7cd5f7009a;p=govpp.git diff --git a/examples/rpc-service/rpc_service.go b/examples/rpc-service/rpc_service.go index ca0c295..e20e5c0 100644 --- a/examples/rpc-service/rpc_service.go +++ b/examples/rpc-service/rpc_service.go @@ -17,18 +17,18 @@ package main import ( - "bytes" "context" "flag" "fmt" "io" "log" + "strings" "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) } @@ -88,6 +81,6 @@ func interfaceDump(ch api.Channel) { if err != nil { log.Fatalln("ERROR: DumpSwInterface failed:", err) } - fmt.Printf("- interface: %s\n", bytes.Trim(iface.InterfaceName, "\x00")) + fmt.Printf("- interface: %s\n", strings.Trim(iface.InterfaceName, "\x00")) } }