forked from gavrilaf/amqp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_mqrpc.gen.go
155 lines (142 loc) · 3.57 KB
/
test_mqrpc.gen.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: test.proto
/*
Package test is a generated protocol buffer package.
It is generated from these files:
test.proto
It has these top-level messages:
Empty
SimpleTypes
ComplexTypes
*/
package test
import fmt "fmt"
import errors "errors"
import rpc "github.com/003random/amqp/rpc"
import proto "github.com/gogo/protobuf/proto"
import math "math"
import _ "github.com/gogo/protobuf/gogoproto"
// Reference imports to suppress errors if they are not otherwise used.
var _ = proto.Marshal
var _ = fmt.Errorf
var _ = math.Inf
// Server API
type TestServer interface {
CopySimple(arg *SimpleTypes) (*SimpleTypes, error)
GenErr(arg *Empty) (*Empty, error)
CopyComplex(arg *ComplexTypes) (*ComplexTypes, error)
}
// Run server API with this call
func RunServer(srv rpc.Server, handler TestServer) {
srv.Serve(func(funcID int32, arg []byte) ([]byte, error) {
switch funcID {
case Functions_CopySimple:
return _Handle_CopySimple(handler, arg)
case Functions_GenErr:
return _Handle_GenErr(handler, arg)
case Functions_CopyComplex:
return _Handle_CopyComplex(handler, arg)
default:
return nil, errors.New(fmt.Sprintf("unknown function with code: %d", funcID))
}
})
}
// Client API
type TestClient interface {
Close()
CopySimple(arg *SimpleTypes) (*SimpleTypes, error)
GenErr(arg *Empty) (*Empty, error)
CopyComplex(arg *ComplexTypes) (*ComplexTypes, error)
}
func NewTestClient(cc rpc.Client) TestClient {
return &testClient{cc}
}
type testClient struct {
cc rpc.Client
}
// Functions enum
const (
Functions_CopySimple int32 = 0
Functions_GenErr int32 = 1
Functions_CopyComplex int32 = 2
)
// Server API handlers
func _Handle_CopySimple(handler interface{}, arg []byte) ([]byte, error) {
var req SimpleTypes
err := req.Unmarshal(arg)
if err != nil {
return nil, err
}
resp, err := handler.(TestServer).CopySimple(&req)
if err != nil {
return nil, err
}
return resp.Marshal()
}
func _Handle_GenErr(handler interface{}, arg []byte) ([]byte, error) {
var req Empty
err := req.Unmarshal(arg)
if err != nil {
return nil, err
}
resp, err := handler.(TestServer).GenErr(&req)
if err != nil {
return nil, err
}
return resp.Marshal()
}
func _Handle_CopyComplex(handler interface{}, arg []byte) ([]byte, error) {
var req ComplexTypes
err := req.Unmarshal(arg)
if err != nil {
return nil, err
}
resp, err := handler.(TestServer).CopyComplex(&req)
if err != nil {
return nil, err
}
return resp.Marshal()
}
// Client API handlers
func (this *testClient) Close() {
this.cc.Close()
}
func (this *testClient) CopySimple(arg *SimpleTypes) (*SimpleTypes, error) {
request, err := arg.Marshal()
if err != nil {
return nil, err
}
respData, err := this.cc.RemoteCall(rpc.Request{FuncID: Functions_CopySimple, Body: request})
if err != nil {
return nil, err
}
var resp SimpleTypes
err = resp.Unmarshal(respData)
return &resp, err
}
func (this *testClient) GenErr(arg *Empty) (*Empty, error) {
request, err := arg.Marshal()
if err != nil {
return nil, err
}
respData, err := this.cc.RemoteCall(rpc.Request{FuncID: Functions_GenErr, Body: request})
if err != nil {
return nil, err
}
var resp Empty
err = resp.Unmarshal(respData)
return &resp, err
}
func (this *testClient) CopyComplex(arg *ComplexTypes) (*ComplexTypes, error) {
request, err := arg.Marshal()
if err != nil {
return nil, err
}
respData, err := this.cc.RemoteCall(rpc.Request{FuncID: Functions_CopyComplex, Body: request})
if err != nil {
return nil, err
}
var resp ComplexTypes
err = resp.Unmarshal(respData)
return &resp, err
}