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