X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=binapi%2Finterface%2Finterface_rpc.ba.go;fp=examples%2Fbinapi%2Finterfaces%2Finterfaces_rpc.ba.go;h=6dc6a430a9e405d61e9b54c5f7bc5650e0a5dc77;hb=d1f24d37bd447b64e402298bb8eb2479681facf9;hp=a7235a87af7595126a9c23f22a3049547afdd7e9;hpb=1548c7e12531e3d055567d761c580a1c7ff0ac40;p=govpp.git diff --git a/examples/binapi/interfaces/interfaces_rpc.ba.go b/binapi/interface/interface_rpc.ba.go similarity index 75% rename from examples/binapi/interfaces/interfaces_rpc.ba.go rename to binapi/interface/interface_rpc.ba.go index a7235a8..6dc6a43 100644 --- a/examples/binapi/interfaces/interfaces_rpc.ba.go +++ b/binapi/interface/interface_rpc.ba.go @@ -4,15 +4,14 @@ package interfaces import ( "context" - "io" - + "fmt" api "git.fd.io/govpp.git/api" + vpe "git.fd.io/govpp.git/binapi/vpe" + "io" ) -// RPCService represents RPC service API for interface module. +// RPCService defines RPC service interface. type RPCService interface { - DumpSwInterface(ctx context.Context, in *SwInterfaceDump) (RPCService_DumpSwInterfaceClient, error) - DumpSwInterfaceRxPlacement(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_DumpSwInterfaceRxPlacementClient, error) CollectDetailedInterfaceStats(ctx context.Context, in *CollectDetailedInterfaceStats) (*CollectDetailedInterfaceStatsReply, error) CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) CreateLoopbackInstance(ctx context.Context, in *CreateLoopbackInstance) (*CreateLoopbackInstanceReply, error) @@ -27,8 +26,10 @@ type RPCService interface { SwInterfaceAddressReplaceBegin(ctx context.Context, in *SwInterfaceAddressReplaceBegin) (*SwInterfaceAddressReplaceBeginReply, error) SwInterfaceAddressReplaceEnd(ctx context.Context, in *SwInterfaceAddressReplaceEnd) (*SwInterfaceAddressReplaceEndReply, error) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) + SwInterfaceDump(ctx context.Context, in *SwInterfaceDump) (RPCService_SwInterfaceDumpClient, error) SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceGetMacAddress) (*SwInterfaceGetMacAddressReply, error) SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) + SwInterfaceRxPlacementDump(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_SwInterfaceRxPlacementDumpClient, error) SwInterfaceSetFlags(ctx context.Context, in *SwInterfaceSetFlags) (*SwInterfaceSetFlagsReply, error) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, in *SwInterfaceSetIPDirectedBroadcast) (*SwInterfaceSetIPDirectedBroadcastReply, error) SwInterfaceSetMacAddress(ctx context.Context, in *SwInterfaceSetMacAddress) (*SwInterfaceSetMacAddressReply, error) @@ -42,68 +43,16 @@ type RPCService interface { } type serviceClient struct { - ch api.Channel -} - -func NewServiceClient(ch api.Channel) RPCService { - return &serviceClient{ch} -} - -func (c *serviceClient) DumpSwInterface(ctx context.Context, in *SwInterfaceDump) (RPCService_DumpSwInterfaceClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSwInterfaceClient{stream} - return x, nil -} - -type RPCService_DumpSwInterfaceClient interface { - Recv() (*SwInterfaceDetails, error) -} - -type serviceClient_DumpSwInterfaceClient struct { - api.MultiRequestCtx + conn api.Connection } -func (c *serviceClient_DumpSwInterfaceClient) Recv() (*SwInterfaceDetails, error) { - m := new(SwInterfaceDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil -} - -func (c *serviceClient) DumpSwInterfaceRxPlacement(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_DumpSwInterfaceRxPlacementClient, error) { - stream := c.ch.SendMultiRequest(in) - x := &serviceClient_DumpSwInterfaceRxPlacementClient{stream} - return x, nil -} - -type RPCService_DumpSwInterfaceRxPlacementClient interface { - Recv() (*SwInterfaceRxPlacementDetails, error) -} - -type serviceClient_DumpSwInterfaceRxPlacementClient struct { - api.MultiRequestCtx -} - -func (c *serviceClient_DumpSwInterfaceRxPlacementClient) Recv() (*SwInterfaceRxPlacementDetails, error) { - m := new(SwInterfaceRxPlacementDetails) - stop, err := c.MultiRequestCtx.ReceiveReply(m) - if err != nil { - return nil, err - } - if stop { - return nil, io.EOF - } - return m, nil +func NewServiceClient(conn api.Connection) RPCService { + return &serviceClient{conn} } func (c *serviceClient) CollectDetailedInterfaceStats(ctx context.Context, in *CollectDetailedInterfaceStats) (*CollectDetailedInterfaceStatsReply, error) { out := new(CollectDetailedInterfaceStatsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -112,7 +61,7 @@ func (c *serviceClient) CollectDetailedInterfaceStats(ctx context.Context, in *C func (c *serviceClient) CreateLoopback(ctx context.Context, in *CreateLoopback) (*CreateLoopbackReply, error) { out := new(CreateLoopbackReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -121,7 +70,7 @@ func (c *serviceClient) CreateLoopback(ctx context.Context, in *CreateLoopback) func (c *serviceClient) CreateLoopbackInstance(ctx context.Context, in *CreateLoopbackInstance) (*CreateLoopbackInstanceReply, error) { out := new(CreateLoopbackInstanceReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -130,7 +79,7 @@ func (c *serviceClient) CreateLoopbackInstance(ctx context.Context, in *CreateLo func (c *serviceClient) CreateSubif(ctx context.Context, in *CreateSubif) (*CreateSubifReply, error) { out := new(CreateSubifReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -139,7 +88,7 @@ func (c *serviceClient) CreateSubif(ctx context.Context, in *CreateSubif) (*Crea func (c *serviceClient) CreateVlanSubif(ctx context.Context, in *CreateVlanSubif) (*CreateVlanSubifReply, error) { out := new(CreateVlanSubifReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -148,7 +97,7 @@ func (c *serviceClient) CreateVlanSubif(ctx context.Context, in *CreateVlanSubif func (c *serviceClient) DeleteLoopback(ctx context.Context, in *DeleteLoopback) (*DeleteLoopbackReply, error) { out := new(DeleteLoopbackReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -157,7 +106,7 @@ func (c *serviceClient) DeleteLoopback(ctx context.Context, in *DeleteLoopback) func (c *serviceClient) DeleteSubif(ctx context.Context, in *DeleteSubif) (*DeleteSubifReply, error) { out := new(DeleteSubifReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -166,7 +115,7 @@ func (c *serviceClient) DeleteSubif(ctx context.Context, in *DeleteSubif) (*Dele func (c *serviceClient) HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSetMtu) (*HwInterfaceSetMtuReply, error) { out := new(HwInterfaceSetMtuReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -175,7 +124,7 @@ func (c *serviceClient) HwInterfaceSetMtu(ctx context.Context, in *HwInterfaceSe func (c *serviceClient) InterfaceNameRenumber(ctx context.Context, in *InterfaceNameRenumber) (*InterfaceNameRenumberReply, error) { out := new(InterfaceNameRenumberReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -184,7 +133,7 @@ func (c *serviceClient) InterfaceNameRenumber(ctx context.Context, in *Interface func (c *serviceClient) SwInterfaceAddDelAddress(ctx context.Context, in *SwInterfaceAddDelAddress) (*SwInterfaceAddDelAddressReply, error) { out := new(SwInterfaceAddDelAddressReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -193,7 +142,7 @@ func (c *serviceClient) SwInterfaceAddDelAddress(ctx context.Context, in *SwInte func (c *serviceClient) SwInterfaceAddDelMacAddress(ctx context.Context, in *SwInterfaceAddDelMacAddress) (*SwInterfaceAddDelMacAddressReply, error) { out := new(SwInterfaceAddDelMacAddressReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -202,7 +151,7 @@ func (c *serviceClient) SwInterfaceAddDelMacAddress(ctx context.Context, in *SwI func (c *serviceClient) SwInterfaceAddressReplaceBegin(ctx context.Context, in *SwInterfaceAddressReplaceBegin) (*SwInterfaceAddressReplaceBeginReply, error) { out := new(SwInterfaceAddressReplaceBeginReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -211,7 +160,7 @@ func (c *serviceClient) SwInterfaceAddressReplaceBegin(ctx context.Context, in * func (c *serviceClient) SwInterfaceAddressReplaceEnd(ctx context.Context, in *SwInterfaceAddressReplaceEnd) (*SwInterfaceAddressReplaceEndReply, error) { out := new(SwInterfaceAddressReplaceEndReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -220,16 +169,55 @@ func (c *serviceClient) SwInterfaceAddressReplaceEnd(ctx context.Context, in *Sw func (c *serviceClient) SwInterfaceClearStats(ctx context.Context, in *SwInterfaceClearStats) (*SwInterfaceClearStatsReply, error) { out := new(SwInterfaceClearStatsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } return out, nil } +func (c *serviceClient) SwInterfaceDump(ctx context.Context, in *SwInterfaceDump) (RPCService_SwInterfaceDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&vpe.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceDumpClient interface { + Recv() (*SwInterfaceDetails, error) + api.Stream +} + +type serviceClient_SwInterfaceDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceDumpClient) Recv() (*SwInterfaceDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwInterfaceDetails: + return m, nil + case *vpe.ControlPingReply: + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + func (c *serviceClient) SwInterfaceGetMacAddress(ctx context.Context, in *SwInterfaceGetMacAddress) (*SwInterfaceGetMacAddressReply, error) { out := new(SwInterfaceGetMacAddressReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -238,16 +226,55 @@ func (c *serviceClient) SwInterfaceGetMacAddress(ctx context.Context, in *SwInte func (c *serviceClient) SwInterfaceGetTable(ctx context.Context, in *SwInterfaceGetTable) (*SwInterfaceGetTableReply, error) { out := new(SwInterfaceGetTableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } return out, nil } +func (c *serviceClient) SwInterfaceRxPlacementDump(ctx context.Context, in *SwInterfaceRxPlacementDump) (RPCService_SwInterfaceRxPlacementDumpClient, error) { + stream, err := c.conn.NewStream(ctx) + if err != nil { + return nil, err + } + x := &serviceClient_SwInterfaceRxPlacementDumpClient{stream} + if err := x.Stream.SendMsg(in); err != nil { + return nil, err + } + if err = x.Stream.SendMsg(&vpe.ControlPing{}); err != nil { + return nil, err + } + return x, nil +} + +type RPCService_SwInterfaceRxPlacementDumpClient interface { + Recv() (*SwInterfaceRxPlacementDetails, error) + api.Stream +} + +type serviceClient_SwInterfaceRxPlacementDumpClient struct { + api.Stream +} + +func (c *serviceClient_SwInterfaceRxPlacementDumpClient) Recv() (*SwInterfaceRxPlacementDetails, error) { + msg, err := c.Stream.RecvMsg() + if err != nil { + return nil, err + } + switch m := msg.(type) { + case *SwInterfaceRxPlacementDetails: + return m, nil + case *vpe.ControlPingReply: + return nil, io.EOF + default: + return nil, fmt.Errorf("unexpected message: %T %v", m, m) + } +} + func (c *serviceClient) SwInterfaceSetFlags(ctx context.Context, in *SwInterfaceSetFlags) (*SwInterfaceSetFlagsReply, error) { out := new(SwInterfaceSetFlagsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -256,7 +283,7 @@ func (c *serviceClient) SwInterfaceSetFlags(ctx context.Context, in *SwInterface func (c *serviceClient) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, in *SwInterfaceSetIPDirectedBroadcast) (*SwInterfaceSetIPDirectedBroadcastReply, error) { out := new(SwInterfaceSetIPDirectedBroadcastReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -265,7 +292,7 @@ func (c *serviceClient) SwInterfaceSetIPDirectedBroadcast(ctx context.Context, i func (c *serviceClient) SwInterfaceSetMacAddress(ctx context.Context, in *SwInterfaceSetMacAddress) (*SwInterfaceSetMacAddressReply, error) { out := new(SwInterfaceSetMacAddressReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -274,7 +301,7 @@ func (c *serviceClient) SwInterfaceSetMacAddress(ctx context.Context, in *SwInte func (c *serviceClient) SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSetMtu) (*SwInterfaceSetMtuReply, error) { out := new(SwInterfaceSetMtuReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -283,7 +310,7 @@ func (c *serviceClient) SwInterfaceSetMtu(ctx context.Context, in *SwInterfaceSe func (c *serviceClient) SwInterfaceSetRxMode(ctx context.Context, in *SwInterfaceSetRxMode) (*SwInterfaceSetRxModeReply, error) { out := new(SwInterfaceSetRxModeReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -292,7 +319,7 @@ func (c *serviceClient) SwInterfaceSetRxMode(ctx context.Context, in *SwInterfac func (c *serviceClient) SwInterfaceSetRxPlacement(ctx context.Context, in *SwInterfaceSetRxPlacement) (*SwInterfaceSetRxPlacementReply, error) { out := new(SwInterfaceSetRxPlacementReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -301,7 +328,7 @@ func (c *serviceClient) SwInterfaceSetRxPlacement(ctx context.Context, in *SwInt func (c *serviceClient) SwInterfaceSetTable(ctx context.Context, in *SwInterfaceSetTable) (*SwInterfaceSetTableReply, error) { out := new(SwInterfaceSetTableReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -310,7 +337,7 @@ func (c *serviceClient) SwInterfaceSetTable(ctx context.Context, in *SwInterface func (c *serviceClient) SwInterfaceSetUnnumbered(ctx context.Context, in *SwInterfaceSetUnnumbered) (*SwInterfaceSetUnnumberedReply, error) { out := new(SwInterfaceSetUnnumberedReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -319,7 +346,7 @@ func (c *serviceClient) SwInterfaceSetUnnumbered(ctx context.Context, in *SwInte func (c *serviceClient) SwInterfaceTagAddDel(ctx context.Context, in *SwInterfaceTagAddDel) (*SwInterfaceTagAddDelReply, error) { out := new(SwInterfaceTagAddDelReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } @@ -328,14 +355,9 @@ func (c *serviceClient) SwInterfaceTagAddDel(ctx context.Context, in *SwInterfac func (c *serviceClient) WantInterfaceEvents(ctx context.Context, in *WantInterfaceEvents) (*WantInterfaceEventsReply, error) { out := new(WantInterfaceEventsReply) - err := c.ch.SendRequest(in).ReceiveReply(out) + err := c.conn.Invoke(ctx, in, out) if err != nil { return nil, err } return out, nil } - -// Reference imports to suppress errors if they are not otherwise used. -var _ = api.RegisterMessage -var _ = context.Background -var _ = io.Copy