76894f0331b6a18531c7641893aaa14fb97f48f7
[govpp.git] / binapi / vpe / vpe_rpc.ba.go
1 // Code generated by GoVPP's binapi-generator. DO NOT EDIT.
2
3 package vpe
4
5 import (
6         "context"
7         "fmt"
8         "io"
9
10         api "git.fd.io/govpp.git/api"
11         memclnt "git.fd.io/govpp.git/binapi/memclnt"
12 )
13
14 // RPCService defines RPC service vpe.
15 type RPCService interface {
16         LogDump(ctx context.Context, in *LogDump) (RPCService_LogDumpClient, error)
17         ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error)
18         ShowVpeSystemTime(ctx context.Context, in *ShowVpeSystemTime) (*ShowVpeSystemTimeReply, error)
19 }
20
21 type serviceClient struct {
22         conn api.Connection
23 }
24
25 func NewServiceClient(conn api.Connection) RPCService {
26         return &serviceClient{conn}
27 }
28
29 func (c *serviceClient) LogDump(ctx context.Context, in *LogDump) (RPCService_LogDumpClient, error) {
30         stream, err := c.conn.NewStream(ctx)
31         if err != nil {
32                 return nil, err
33         }
34         x := &serviceClient_LogDumpClient{stream}
35         if err := x.Stream.SendMsg(in); err != nil {
36                 return nil, err
37         }
38         if err = x.Stream.SendMsg(&memclnt.ControlPing{}); err != nil {
39                 return nil, err
40         }
41         return x, nil
42 }
43
44 type RPCService_LogDumpClient interface {
45         Recv() (*LogDetails, error)
46         api.Stream
47 }
48
49 type serviceClient_LogDumpClient struct {
50         api.Stream
51 }
52
53 func (c *serviceClient_LogDumpClient) Recv() (*LogDetails, error) {
54         msg, err := c.Stream.RecvMsg()
55         if err != nil {
56                 return nil, err
57         }
58         switch m := msg.(type) {
59         case *LogDetails:
60                 return m, nil
61         case *memclnt.ControlPingReply:
62                 err = c.Stream.Close()
63                 if err != nil {
64                         return nil, err
65                 }
66                 return nil, io.EOF
67         default:
68                 return nil, fmt.Errorf("unexpected message: %T %v", m, m)
69         }
70 }
71
72 func (c *serviceClient) ShowVersion(ctx context.Context, in *ShowVersion) (*ShowVersionReply, error) {
73         out := new(ShowVersionReply)
74         err := c.conn.Invoke(ctx, in, out)
75         if err != nil {
76                 return nil, err
77         }
78         return out, api.RetvalToVPPApiError(out.Retval)
79 }
80
81 func (c *serviceClient) ShowVpeSystemTime(ctx context.Context, in *ShowVpeSystemTime) (*ShowVpeSystemTimeReply, error) {
82         out := new(ShowVpeSystemTimeReply)
83         err := c.conn.Invoke(ctx, in, out)
84         if err != nil {
85                 return nil, err
86         }
87         return out, api.RetvalToVPPApiError(out.Retval)
88 }