7ae3a0eec61c04d14f9504a9e159138a043fc8d1
[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 "git.fd.io/govpp.git/api"
11         vpe "git.fd.io/govpp.git/binapi/vpe"
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(&vpe.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 *vpe.ControlPingReply:
81                 return nil, io.EOF
82         default:
83                 return nil, fmt.Errorf("unexpected message: %T %v", m, m)
84         }
85 }
86
87 func (c *serviceClient) PolicerInput(ctx context.Context, in *PolicerInput) (*PolicerInputReply, error) {
88         out := new(PolicerInputReply)
89         err := c.conn.Invoke(ctx, in, out)
90         if err != nil {
91                 return nil, err
92         }
93         return out, api.RetvalToVPPApiError(out.Retval)
94 }