starpc 0.1.7 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Makefile +1 -0
- package/README.md +24 -5
- package/dist/echo/client-test.d.ts +2 -0
- package/dist/echo/client-test.js +35 -0
- package/dist/echo/echo.d.ts +124 -0
- package/dist/echo/echo.js +42 -0
- package/dist/echo/index.d.ts +3 -0
- package/dist/echo/index.js +3 -0
- package/dist/echo/server.d.ts +8 -0
- package/dist/echo/server.js +50 -0
- package/dist/echo/sever.d.ts +0 -0
- package/dist/echo/sever.js +1 -0
- package/dist/srpc/broadcast-channel.d.ts +3 -2
- package/dist/srpc/broadcast-channel.js +2 -2
- package/dist/srpc/client-rpc.d.ts +4 -28
- package/dist/srpc/client-rpc.js +9 -152
- package/dist/srpc/client.d.ts +2 -2
- package/dist/srpc/client.js +56 -84
- package/dist/srpc/common-rpc.d.ts +24 -0
- package/dist/srpc/common-rpc.js +140 -0
- package/dist/srpc/conn.d.ts +8 -3
- package/dist/srpc/conn.js +19 -3
- package/dist/srpc/definition.d.ts +15 -0
- package/dist/srpc/definition.js +1 -0
- package/dist/srpc/handler.d.ts +24 -0
- package/dist/srpc/handler.js +123 -0
- package/dist/srpc/index.d.ts +7 -3
- package/dist/srpc/index.js +6 -2
- package/dist/srpc/message.d.ts +11 -0
- package/dist/srpc/message.js +32 -0
- package/dist/srpc/mux.d.ts +11 -0
- package/dist/srpc/mux.js +36 -0
- package/dist/srpc/packet.d.ts +4 -4
- package/dist/srpc/packet.js +38 -27
- package/dist/srpc/rpcproto.d.ts +18 -43
- package/dist/srpc/rpcproto.js +37 -78
- package/dist/srpc/server-rpc.d.ts +11 -0
- package/dist/srpc/server-rpc.js +55 -0
- package/dist/srpc/server.d.ts +14 -0
- package/dist/srpc/server.js +31 -0
- package/dist/srpc/websocket.d.ts +3 -2
- package/dist/srpc/websocket.js +4 -4
- package/e2e/README.md +10 -0
- package/e2e/e2e.ts +27 -0
- package/echo/client-test.ts +41 -0
- package/echo/echo.ts +45 -0
- package/echo/index.ts +3 -0
- package/echo/server.ts +57 -0
- package/echo/sever.ts +0 -0
- package/integration/integration.bash +1 -1
- package/integration/integration.ts +10 -42
- package/package.json +18 -17
- package/srpc/broadcast-channel.ts +8 -3
- package/srpc/client-rpc.go +1 -9
- package/srpc/client-rpc.ts +11 -175
- package/srpc/client.ts +58 -99
- package/srpc/common-rpc.ts +171 -0
- package/srpc/conn.ts +33 -5
- package/srpc/definition.ts +30 -0
- package/srpc/handler.ts +174 -0
- package/srpc/index.ts +7 -3
- package/srpc/message.ts +60 -0
- package/srpc/mux.ts +56 -0
- package/srpc/packet.go +4 -11
- package/srpc/packet.ts +44 -30
- package/srpc/rpcproto.pb.go +54 -118
- package/srpc/rpcproto.proto +7 -12
- package/srpc/rpcproto.ts +38 -101
- package/srpc/rpcproto_vtproto.pb.go +58 -210
- package/srpc/server-rpc.go +5 -10
- package/srpc/server-rpc.ts +65 -0
- package/srpc/server.ts +56 -0
- package/srpc/websocket.ts +6 -4
package/srpc/rpcproto.ts
CHANGED
|
@@ -8,7 +8,6 @@ export const protobufPackage = 'srpc'
|
|
|
8
8
|
export interface Packet {
|
|
9
9
|
body?:
|
|
10
10
|
| { $case: 'callStart'; callStart: CallStart }
|
|
11
|
-
| { $case: 'callStartResp'; callStartResp: CallStartResp }
|
|
12
11
|
| { $case: 'callData'; callData: CallData }
|
|
13
12
|
}
|
|
14
13
|
|
|
@@ -29,21 +28,16 @@ export interface CallStart {
|
|
|
29
28
|
* Optional if streaming.
|
|
30
29
|
*/
|
|
31
30
|
data: Uint8Array
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
/** CallStartResp is the response to CallStart. */
|
|
35
|
-
export interface CallStartResp {
|
|
36
|
-
/**
|
|
37
|
-
* Error contains any error starting the RPC call.
|
|
38
|
-
* Empty if successful.
|
|
39
|
-
*/
|
|
40
|
-
error: string
|
|
31
|
+
/** DataIsZero indicates Data is set with an empty message. */
|
|
32
|
+
dataIsZero: boolean
|
|
41
33
|
}
|
|
42
34
|
|
|
43
35
|
/** CallData contains a message in a streaming RPC sequence. */
|
|
44
36
|
export interface CallData {
|
|
45
37
|
/** Data contains the packet in the sequence. */
|
|
46
38
|
data: Uint8Array
|
|
39
|
+
/** DataIsZero indicates Data is set with an empty message. */
|
|
40
|
+
dataIsZero: boolean
|
|
47
41
|
/** Complete indicates the RPC call is completed. */
|
|
48
42
|
complete: boolean
|
|
49
43
|
/**
|
|
@@ -68,14 +62,8 @@ export const Packet = {
|
|
|
68
62
|
writer.uint32(10).fork()
|
|
69
63
|
).ldelim()
|
|
70
64
|
}
|
|
71
|
-
if (message.body?.$case === 'callStartResp') {
|
|
72
|
-
CallStartResp.encode(
|
|
73
|
-
message.body.callStartResp,
|
|
74
|
-
writer.uint32(18).fork()
|
|
75
|
-
).ldelim()
|
|
76
|
-
}
|
|
77
65
|
if (message.body?.$case === 'callData') {
|
|
78
|
-
CallData.encode(message.body.callData, writer.uint32(
|
|
66
|
+
CallData.encode(message.body.callData, writer.uint32(18).fork()).ldelim()
|
|
79
67
|
}
|
|
80
68
|
return writer
|
|
81
69
|
},
|
|
@@ -94,12 +82,6 @@ export const Packet = {
|
|
|
94
82
|
}
|
|
95
83
|
break
|
|
96
84
|
case 2:
|
|
97
|
-
message.body = {
|
|
98
|
-
$case: 'callStartResp',
|
|
99
|
-
callStartResp: CallStartResp.decode(reader, reader.uint32()),
|
|
100
|
-
}
|
|
101
|
-
break
|
|
102
|
-
case 3:
|
|
103
85
|
message.body = {
|
|
104
86
|
$case: 'callData',
|
|
105
87
|
callData: CallData.decode(reader, reader.uint32()),
|
|
@@ -120,11 +102,6 @@ export const Packet = {
|
|
|
120
102
|
$case: 'callStart',
|
|
121
103
|
callStart: CallStart.fromJSON(object.callStart),
|
|
122
104
|
}
|
|
123
|
-
: isSet(object.callStartResp)
|
|
124
|
-
? {
|
|
125
|
-
$case: 'callStartResp',
|
|
126
|
-
callStartResp: CallStartResp.fromJSON(object.callStartResp),
|
|
127
|
-
}
|
|
128
105
|
: isSet(object.callData)
|
|
129
106
|
? { $case: 'callData', callData: CallData.fromJSON(object.callData) }
|
|
130
107
|
: undefined,
|
|
@@ -137,10 +114,6 @@ export const Packet = {
|
|
|
137
114
|
(obj.callStart = message.body?.callStart
|
|
138
115
|
? CallStart.toJSON(message.body?.callStart)
|
|
139
116
|
: undefined)
|
|
140
|
-
message.body?.$case === 'callStartResp' &&
|
|
141
|
-
(obj.callStartResp = message.body?.callStartResp
|
|
142
|
-
? CallStartResp.toJSON(message.body?.callStartResp)
|
|
143
|
-
: undefined)
|
|
144
117
|
message.body?.$case === 'callData' &&
|
|
145
118
|
(obj.callData = message.body?.callData
|
|
146
119
|
? CallData.toJSON(message.body?.callData)
|
|
@@ -160,16 +133,6 @@ export const Packet = {
|
|
|
160
133
|
callStart: CallStart.fromPartial(object.body.callStart),
|
|
161
134
|
}
|
|
162
135
|
}
|
|
163
|
-
if (
|
|
164
|
-
object.body?.$case === 'callStartResp' &&
|
|
165
|
-
object.body?.callStartResp !== undefined &&
|
|
166
|
-
object.body?.callStartResp !== null
|
|
167
|
-
) {
|
|
168
|
-
message.body = {
|
|
169
|
-
$case: 'callStartResp',
|
|
170
|
-
callStartResp: CallStartResp.fromPartial(object.body.callStartResp),
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
136
|
if (
|
|
174
137
|
object.body?.$case === 'callData' &&
|
|
175
138
|
object.body?.callData !== undefined &&
|
|
@@ -185,7 +148,12 @@ export const Packet = {
|
|
|
185
148
|
}
|
|
186
149
|
|
|
187
150
|
function createBaseCallStart(): CallStart {
|
|
188
|
-
return {
|
|
151
|
+
return {
|
|
152
|
+
rpcService: '',
|
|
153
|
+
rpcMethod: '',
|
|
154
|
+
data: new Uint8Array(),
|
|
155
|
+
dataIsZero: false,
|
|
156
|
+
}
|
|
189
157
|
}
|
|
190
158
|
|
|
191
159
|
export const CallStart = {
|
|
@@ -202,6 +170,9 @@ export const CallStart = {
|
|
|
202
170
|
if (message.data.length !== 0) {
|
|
203
171
|
writer.uint32(26).bytes(message.data)
|
|
204
172
|
}
|
|
173
|
+
if (message.dataIsZero === true) {
|
|
174
|
+
writer.uint32(32).bool(message.dataIsZero)
|
|
175
|
+
}
|
|
205
176
|
return writer
|
|
206
177
|
},
|
|
207
178
|
|
|
@@ -221,6 +192,9 @@ export const CallStart = {
|
|
|
221
192
|
case 3:
|
|
222
193
|
message.data = reader.bytes()
|
|
223
194
|
break
|
|
195
|
+
case 4:
|
|
196
|
+
message.dataIsZero = reader.bool()
|
|
197
|
+
break
|
|
224
198
|
default:
|
|
225
199
|
reader.skipType(tag & 7)
|
|
226
200
|
break
|
|
@@ -236,6 +210,7 @@ export const CallStart = {
|
|
|
236
210
|
data: isSet(object.data)
|
|
237
211
|
? bytesFromBase64(object.data)
|
|
238
212
|
: new Uint8Array(),
|
|
213
|
+
dataIsZero: isSet(object.dataIsZero) ? Boolean(object.dataIsZero) : false,
|
|
239
214
|
}
|
|
240
215
|
},
|
|
241
216
|
|
|
@@ -247,6 +222,7 @@ export const CallStart = {
|
|
|
247
222
|
(obj.data = base64FromBytes(
|
|
248
223
|
message.data !== undefined ? message.data : new Uint8Array()
|
|
249
224
|
))
|
|
225
|
+
message.dataIsZero !== undefined && (obj.dataIsZero = message.dataIsZero)
|
|
250
226
|
return obj
|
|
251
227
|
},
|
|
252
228
|
|
|
@@ -257,66 +233,18 @@ export const CallStart = {
|
|
|
257
233
|
message.rpcService = object.rpcService ?? ''
|
|
258
234
|
message.rpcMethod = object.rpcMethod ?? ''
|
|
259
235
|
message.data = object.data ?? new Uint8Array()
|
|
260
|
-
|
|
261
|
-
},
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
function createBaseCallStartResp(): CallStartResp {
|
|
265
|
-
return { error: '' }
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
export const CallStartResp = {
|
|
269
|
-
encode(
|
|
270
|
-
message: CallStartResp,
|
|
271
|
-
writer: _m0.Writer = _m0.Writer.create()
|
|
272
|
-
): _m0.Writer {
|
|
273
|
-
if (message.error !== '') {
|
|
274
|
-
writer.uint32(10).string(message.error)
|
|
275
|
-
}
|
|
276
|
-
return writer
|
|
277
|
-
},
|
|
278
|
-
|
|
279
|
-
decode(input: _m0.Reader | Uint8Array, length?: number): CallStartResp {
|
|
280
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input)
|
|
281
|
-
let end = length === undefined ? reader.len : reader.pos + length
|
|
282
|
-
const message = createBaseCallStartResp()
|
|
283
|
-
while (reader.pos < end) {
|
|
284
|
-
const tag = reader.uint32()
|
|
285
|
-
switch (tag >>> 3) {
|
|
286
|
-
case 1:
|
|
287
|
-
message.error = reader.string()
|
|
288
|
-
break
|
|
289
|
-
default:
|
|
290
|
-
reader.skipType(tag & 7)
|
|
291
|
-
break
|
|
292
|
-
}
|
|
293
|
-
}
|
|
294
|
-
return message
|
|
295
|
-
},
|
|
296
|
-
|
|
297
|
-
fromJSON(object: any): CallStartResp {
|
|
298
|
-
return {
|
|
299
|
-
error: isSet(object.error) ? String(object.error) : '',
|
|
300
|
-
}
|
|
301
|
-
},
|
|
302
|
-
|
|
303
|
-
toJSON(message: CallStartResp): unknown {
|
|
304
|
-
const obj: any = {}
|
|
305
|
-
message.error !== undefined && (obj.error = message.error)
|
|
306
|
-
return obj
|
|
307
|
-
},
|
|
308
|
-
|
|
309
|
-
fromPartial<I extends Exact<DeepPartial<CallStartResp>, I>>(
|
|
310
|
-
object: I
|
|
311
|
-
): CallStartResp {
|
|
312
|
-
const message = createBaseCallStartResp()
|
|
313
|
-
message.error = object.error ?? ''
|
|
236
|
+
message.dataIsZero = object.dataIsZero ?? false
|
|
314
237
|
return message
|
|
315
238
|
},
|
|
316
239
|
}
|
|
317
240
|
|
|
318
241
|
function createBaseCallData(): CallData {
|
|
319
|
-
return {
|
|
242
|
+
return {
|
|
243
|
+
data: new Uint8Array(),
|
|
244
|
+
dataIsZero: false,
|
|
245
|
+
complete: false,
|
|
246
|
+
error: '',
|
|
247
|
+
}
|
|
320
248
|
}
|
|
321
249
|
|
|
322
250
|
export const CallData = {
|
|
@@ -327,11 +255,14 @@ export const CallData = {
|
|
|
327
255
|
if (message.data.length !== 0) {
|
|
328
256
|
writer.uint32(10).bytes(message.data)
|
|
329
257
|
}
|
|
258
|
+
if (message.dataIsZero === true) {
|
|
259
|
+
writer.uint32(16).bool(message.dataIsZero)
|
|
260
|
+
}
|
|
330
261
|
if (message.complete === true) {
|
|
331
|
-
writer.uint32(
|
|
262
|
+
writer.uint32(24).bool(message.complete)
|
|
332
263
|
}
|
|
333
264
|
if (message.error !== '') {
|
|
334
|
-
writer.uint32(
|
|
265
|
+
writer.uint32(34).string(message.error)
|
|
335
266
|
}
|
|
336
267
|
return writer
|
|
337
268
|
},
|
|
@@ -347,9 +278,12 @@ export const CallData = {
|
|
|
347
278
|
message.data = reader.bytes()
|
|
348
279
|
break
|
|
349
280
|
case 2:
|
|
350
|
-
message.
|
|
281
|
+
message.dataIsZero = reader.bool()
|
|
351
282
|
break
|
|
352
283
|
case 3:
|
|
284
|
+
message.complete = reader.bool()
|
|
285
|
+
break
|
|
286
|
+
case 4:
|
|
353
287
|
message.error = reader.string()
|
|
354
288
|
break
|
|
355
289
|
default:
|
|
@@ -365,6 +299,7 @@ export const CallData = {
|
|
|
365
299
|
data: isSet(object.data)
|
|
366
300
|
? bytesFromBase64(object.data)
|
|
367
301
|
: new Uint8Array(),
|
|
302
|
+
dataIsZero: isSet(object.dataIsZero) ? Boolean(object.dataIsZero) : false,
|
|
368
303
|
complete: isSet(object.complete) ? Boolean(object.complete) : false,
|
|
369
304
|
error: isSet(object.error) ? String(object.error) : '',
|
|
370
305
|
}
|
|
@@ -376,6 +311,7 @@ export const CallData = {
|
|
|
376
311
|
(obj.data = base64FromBytes(
|
|
377
312
|
message.data !== undefined ? message.data : new Uint8Array()
|
|
378
313
|
))
|
|
314
|
+
message.dataIsZero !== undefined && (obj.dataIsZero = message.dataIsZero)
|
|
379
315
|
message.complete !== undefined && (obj.complete = message.complete)
|
|
380
316
|
message.error !== undefined && (obj.error = message.error)
|
|
381
317
|
return obj
|
|
@@ -384,6 +320,7 @@ export const CallData = {
|
|
|
384
320
|
fromPartial<I extends Exact<DeepPartial<CallData>, I>>(object: I): CallData {
|
|
385
321
|
const message = createBaseCallData()
|
|
386
322
|
message.data = object.data ?? new Uint8Array()
|
|
323
|
+
message.dataIsZero = object.dataIsZero ?? false
|
|
387
324
|
message.complete = object.complete ?? false
|
|
388
325
|
message.error = object.error ?? ''
|
|
389
326
|
return message
|
|
@@ -34,9 +34,6 @@ func (this *Packet) EqualVT(that *Packet) bool {
|
|
|
34
34
|
if !this.GetCallStart().EqualVT(that.GetCallStart()) {
|
|
35
35
|
return false
|
|
36
36
|
}
|
|
37
|
-
if !this.GetCallStartResp().EqualVT(that.GetCallStartResp()) {
|
|
38
|
-
return false
|
|
39
|
-
}
|
|
40
37
|
if !this.GetCallData().EqualVT(that.GetCallData()) {
|
|
41
38
|
return false
|
|
42
39
|
}
|
|
@@ -59,16 +56,7 @@ func (this *CallStart) EqualVT(that *CallStart) bool {
|
|
|
59
56
|
if string(this.Data) != string(that.Data) {
|
|
60
57
|
return false
|
|
61
58
|
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
func (this *CallStartResp) EqualVT(that *CallStartResp) bool {
|
|
66
|
-
if this == nil {
|
|
67
|
-
return that == nil || that.String() == ""
|
|
68
|
-
} else if that == nil {
|
|
69
|
-
return this.String() == ""
|
|
70
|
-
}
|
|
71
|
-
if this.Error != that.Error {
|
|
59
|
+
if this.DataIsZero != that.DataIsZero {
|
|
72
60
|
return false
|
|
73
61
|
}
|
|
74
62
|
return string(this.unknownFields) == string(that.unknownFields)
|
|
@@ -83,6 +71,9 @@ func (this *CallData) EqualVT(that *CallData) bool {
|
|
|
83
71
|
if string(this.Data) != string(that.Data) {
|
|
84
72
|
return false
|
|
85
73
|
}
|
|
74
|
+
if this.DataIsZero != that.DataIsZero {
|
|
75
|
+
return false
|
|
76
|
+
}
|
|
86
77
|
if this.Complete != that.Complete {
|
|
87
78
|
return false
|
|
88
79
|
}
|
|
@@ -153,25 +144,6 @@ func (m *Packet_CallStart) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
|
|
153
144
|
}
|
|
154
145
|
return len(dAtA) - i, nil
|
|
155
146
|
}
|
|
156
|
-
func (m *Packet_CallStartResp) MarshalToVT(dAtA []byte) (int, error) {
|
|
157
|
-
size := m.SizeVT()
|
|
158
|
-
return m.MarshalToSizedBufferVT(dAtA[:size])
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
func (m *Packet_CallStartResp) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
|
162
|
-
i := len(dAtA)
|
|
163
|
-
if m.CallStartResp != nil {
|
|
164
|
-
size, err := m.CallStartResp.MarshalToSizedBufferVT(dAtA[:i])
|
|
165
|
-
if err != nil {
|
|
166
|
-
return 0, err
|
|
167
|
-
}
|
|
168
|
-
i -= size
|
|
169
|
-
i = encodeVarint(dAtA, i, uint64(size))
|
|
170
|
-
i--
|
|
171
|
-
dAtA[i] = 0x12
|
|
172
|
-
}
|
|
173
|
-
return len(dAtA) - i, nil
|
|
174
|
-
}
|
|
175
147
|
func (m *Packet_CallData) MarshalToVT(dAtA []byte) (int, error) {
|
|
176
148
|
size := m.SizeVT()
|
|
177
149
|
return m.MarshalToSizedBufferVT(dAtA[:size])
|
|
@@ -187,7 +159,7 @@ func (m *Packet_CallData) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
|
|
187
159
|
i -= size
|
|
188
160
|
i = encodeVarint(dAtA, i, uint64(size))
|
|
189
161
|
i--
|
|
190
|
-
dAtA[i] =
|
|
162
|
+
dAtA[i] = 0x12
|
|
191
163
|
}
|
|
192
164
|
return len(dAtA) - i, nil
|
|
193
165
|
}
|
|
@@ -221,6 +193,16 @@ func (m *CallStart) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
|
|
221
193
|
i -= len(m.unknownFields)
|
|
222
194
|
copy(dAtA[i:], m.unknownFields)
|
|
223
195
|
}
|
|
196
|
+
if m.DataIsZero {
|
|
197
|
+
i--
|
|
198
|
+
if m.DataIsZero {
|
|
199
|
+
dAtA[i] = 1
|
|
200
|
+
} else {
|
|
201
|
+
dAtA[i] = 0
|
|
202
|
+
}
|
|
203
|
+
i--
|
|
204
|
+
dAtA[i] = 0x20
|
|
205
|
+
}
|
|
224
206
|
if len(m.Data) > 0 {
|
|
225
207
|
i -= len(m.Data)
|
|
226
208
|
copy(dAtA[i:], m.Data)
|
|
@@ -245,46 +227,6 @@ func (m *CallStart) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
|
|
245
227
|
return len(dAtA) - i, nil
|
|
246
228
|
}
|
|
247
229
|
|
|
248
|
-
func (m *CallStartResp) MarshalVT() (dAtA []byte, err error) {
|
|
249
|
-
if m == nil {
|
|
250
|
-
return nil, nil
|
|
251
|
-
}
|
|
252
|
-
size := m.SizeVT()
|
|
253
|
-
dAtA = make([]byte, size)
|
|
254
|
-
n, err := m.MarshalToSizedBufferVT(dAtA[:size])
|
|
255
|
-
if err != nil {
|
|
256
|
-
return nil, err
|
|
257
|
-
}
|
|
258
|
-
return dAtA[:n], nil
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
func (m *CallStartResp) MarshalToVT(dAtA []byte) (int, error) {
|
|
262
|
-
size := m.SizeVT()
|
|
263
|
-
return m.MarshalToSizedBufferVT(dAtA[:size])
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
func (m *CallStartResp) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
|
267
|
-
if m == nil {
|
|
268
|
-
return 0, nil
|
|
269
|
-
}
|
|
270
|
-
i := len(dAtA)
|
|
271
|
-
_ = i
|
|
272
|
-
var l int
|
|
273
|
-
_ = l
|
|
274
|
-
if m.unknownFields != nil {
|
|
275
|
-
i -= len(m.unknownFields)
|
|
276
|
-
copy(dAtA[i:], m.unknownFields)
|
|
277
|
-
}
|
|
278
|
-
if len(m.Error) > 0 {
|
|
279
|
-
i -= len(m.Error)
|
|
280
|
-
copy(dAtA[i:], m.Error)
|
|
281
|
-
i = encodeVarint(dAtA, i, uint64(len(m.Error)))
|
|
282
|
-
i--
|
|
283
|
-
dAtA[i] = 0xa
|
|
284
|
-
}
|
|
285
|
-
return len(dAtA) - i, nil
|
|
286
|
-
}
|
|
287
|
-
|
|
288
230
|
func (m *CallData) MarshalVT() (dAtA []byte, err error) {
|
|
289
231
|
if m == nil {
|
|
290
232
|
return nil, nil
|
|
@@ -320,7 +262,7 @@ func (m *CallData) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
|
|
320
262
|
copy(dAtA[i:], m.Error)
|
|
321
263
|
i = encodeVarint(dAtA, i, uint64(len(m.Error)))
|
|
322
264
|
i--
|
|
323
|
-
dAtA[i] =
|
|
265
|
+
dAtA[i] = 0x22
|
|
324
266
|
}
|
|
325
267
|
if m.Complete {
|
|
326
268
|
i--
|
|
@@ -330,6 +272,16 @@ func (m *CallData) MarshalToSizedBufferVT(dAtA []byte) (int, error) {
|
|
|
330
272
|
dAtA[i] = 0
|
|
331
273
|
}
|
|
332
274
|
i--
|
|
275
|
+
dAtA[i] = 0x18
|
|
276
|
+
}
|
|
277
|
+
if m.DataIsZero {
|
|
278
|
+
i--
|
|
279
|
+
if m.DataIsZero {
|
|
280
|
+
dAtA[i] = 1
|
|
281
|
+
} else {
|
|
282
|
+
dAtA[i] = 0
|
|
283
|
+
}
|
|
284
|
+
i--
|
|
333
285
|
dAtA[i] = 0x10
|
|
334
286
|
}
|
|
335
287
|
if len(m.Data) > 0 {
|
|
@@ -378,18 +330,6 @@ func (m *Packet_CallStart) SizeVT() (n int) {
|
|
|
378
330
|
}
|
|
379
331
|
return n
|
|
380
332
|
}
|
|
381
|
-
func (m *Packet_CallStartResp) SizeVT() (n int) {
|
|
382
|
-
if m == nil {
|
|
383
|
-
return 0
|
|
384
|
-
}
|
|
385
|
-
var l int
|
|
386
|
-
_ = l
|
|
387
|
-
if m.CallStartResp != nil {
|
|
388
|
-
l = m.CallStartResp.SizeVT()
|
|
389
|
-
n += 1 + l + sov(uint64(l))
|
|
390
|
-
}
|
|
391
|
-
return n
|
|
392
|
-
}
|
|
393
333
|
func (m *Packet_CallData) SizeVT() (n int) {
|
|
394
334
|
if m == nil {
|
|
395
335
|
return 0
|
|
@@ -420,19 +360,8 @@ func (m *CallStart) SizeVT() (n int) {
|
|
|
420
360
|
if l > 0 {
|
|
421
361
|
n += 1 + l + sov(uint64(l))
|
|
422
362
|
}
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
func (m *CallStartResp) SizeVT() (n int) {
|
|
428
|
-
if m == nil {
|
|
429
|
-
return 0
|
|
430
|
-
}
|
|
431
|
-
var l int
|
|
432
|
-
_ = l
|
|
433
|
-
l = len(m.Error)
|
|
434
|
-
if l > 0 {
|
|
435
|
-
n += 1 + l + sov(uint64(l))
|
|
363
|
+
if m.DataIsZero {
|
|
364
|
+
n += 2
|
|
436
365
|
}
|
|
437
366
|
n += len(m.unknownFields)
|
|
438
367
|
return n
|
|
@@ -448,6 +377,9 @@ func (m *CallData) SizeVT() (n int) {
|
|
|
448
377
|
if l > 0 {
|
|
449
378
|
n += 1 + l + sov(uint64(l))
|
|
450
379
|
}
|
|
380
|
+
if m.DataIsZero {
|
|
381
|
+
n += 2
|
|
382
|
+
}
|
|
451
383
|
if m.Complete {
|
|
452
384
|
n += 2
|
|
453
385
|
}
|
|
@@ -536,47 +468,6 @@ func (m *Packet) UnmarshalVT(dAtA []byte) error {
|
|
|
536
468
|
}
|
|
537
469
|
iNdEx = postIndex
|
|
538
470
|
case 2:
|
|
539
|
-
if wireType != 2 {
|
|
540
|
-
return fmt.Errorf("proto: wrong wireType = %d for field CallStartResp", wireType)
|
|
541
|
-
}
|
|
542
|
-
var msglen int
|
|
543
|
-
for shift := uint(0); ; shift += 7 {
|
|
544
|
-
if shift >= 64 {
|
|
545
|
-
return ErrIntOverflow
|
|
546
|
-
}
|
|
547
|
-
if iNdEx >= l {
|
|
548
|
-
return io.ErrUnexpectedEOF
|
|
549
|
-
}
|
|
550
|
-
b := dAtA[iNdEx]
|
|
551
|
-
iNdEx++
|
|
552
|
-
msglen |= int(b&0x7F) << shift
|
|
553
|
-
if b < 0x80 {
|
|
554
|
-
break
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
if msglen < 0 {
|
|
558
|
-
return ErrInvalidLength
|
|
559
|
-
}
|
|
560
|
-
postIndex := iNdEx + msglen
|
|
561
|
-
if postIndex < 0 {
|
|
562
|
-
return ErrInvalidLength
|
|
563
|
-
}
|
|
564
|
-
if postIndex > l {
|
|
565
|
-
return io.ErrUnexpectedEOF
|
|
566
|
-
}
|
|
567
|
-
if oneof, ok := m.Body.(*Packet_CallStartResp); ok {
|
|
568
|
-
if err := oneof.CallStartResp.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil {
|
|
569
|
-
return err
|
|
570
|
-
}
|
|
571
|
-
} else {
|
|
572
|
-
v := &CallStartResp{}
|
|
573
|
-
if err := v.UnmarshalVT(dAtA[iNdEx:postIndex]); err != nil {
|
|
574
|
-
return err
|
|
575
|
-
}
|
|
576
|
-
m.Body = &Packet_CallStartResp{v}
|
|
577
|
-
}
|
|
578
|
-
iNdEx = postIndex
|
|
579
|
-
case 3:
|
|
580
471
|
if wireType != 2 {
|
|
581
472
|
return fmt.Errorf("proto: wrong wireType = %d for field CallData", wireType)
|
|
582
473
|
}
|
|
@@ -766,62 +657,11 @@ func (m *CallStart) UnmarshalVT(dAtA []byte) error {
|
|
|
766
657
|
m.Data = []byte{}
|
|
767
658
|
}
|
|
768
659
|
iNdEx = postIndex
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
if err != nil {
|
|
773
|
-
return err
|
|
774
|
-
}
|
|
775
|
-
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
|
776
|
-
return ErrInvalidLength
|
|
777
|
-
}
|
|
778
|
-
if (iNdEx + skippy) > l {
|
|
779
|
-
return io.ErrUnexpectedEOF
|
|
780
|
-
}
|
|
781
|
-
m.unknownFields = append(m.unknownFields, dAtA[iNdEx:iNdEx+skippy]...)
|
|
782
|
-
iNdEx += skippy
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
if iNdEx > l {
|
|
787
|
-
return io.ErrUnexpectedEOF
|
|
788
|
-
}
|
|
789
|
-
return nil
|
|
790
|
-
}
|
|
791
|
-
func (m *CallStartResp) UnmarshalVT(dAtA []byte) error {
|
|
792
|
-
l := len(dAtA)
|
|
793
|
-
iNdEx := 0
|
|
794
|
-
for iNdEx < l {
|
|
795
|
-
preIndex := iNdEx
|
|
796
|
-
var wire uint64
|
|
797
|
-
for shift := uint(0); ; shift += 7 {
|
|
798
|
-
if shift >= 64 {
|
|
799
|
-
return ErrIntOverflow
|
|
800
|
-
}
|
|
801
|
-
if iNdEx >= l {
|
|
802
|
-
return io.ErrUnexpectedEOF
|
|
803
|
-
}
|
|
804
|
-
b := dAtA[iNdEx]
|
|
805
|
-
iNdEx++
|
|
806
|
-
wire |= uint64(b&0x7F) << shift
|
|
807
|
-
if b < 0x80 {
|
|
808
|
-
break
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
fieldNum := int32(wire >> 3)
|
|
812
|
-
wireType := int(wire & 0x7)
|
|
813
|
-
if wireType == 4 {
|
|
814
|
-
return fmt.Errorf("proto: CallStartResp: wiretype end group for non-group")
|
|
815
|
-
}
|
|
816
|
-
if fieldNum <= 0 {
|
|
817
|
-
return fmt.Errorf("proto: CallStartResp: illegal tag %d (wire type %d)", fieldNum, wire)
|
|
818
|
-
}
|
|
819
|
-
switch fieldNum {
|
|
820
|
-
case 1:
|
|
821
|
-
if wireType != 2 {
|
|
822
|
-
return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType)
|
|
660
|
+
case 4:
|
|
661
|
+
if wireType != 0 {
|
|
662
|
+
return fmt.Errorf("proto: wrong wireType = %d for field DataIsZero", wireType)
|
|
823
663
|
}
|
|
824
|
-
var
|
|
664
|
+
var v int
|
|
825
665
|
for shift := uint(0); ; shift += 7 {
|
|
826
666
|
if shift >= 64 {
|
|
827
667
|
return ErrIntOverflow
|
|
@@ -831,24 +671,12 @@ func (m *CallStartResp) UnmarshalVT(dAtA []byte) error {
|
|
|
831
671
|
}
|
|
832
672
|
b := dAtA[iNdEx]
|
|
833
673
|
iNdEx++
|
|
834
|
-
|
|
674
|
+
v |= int(b&0x7F) << shift
|
|
835
675
|
if b < 0x80 {
|
|
836
676
|
break
|
|
837
677
|
}
|
|
838
678
|
}
|
|
839
|
-
|
|
840
|
-
if intStringLen < 0 {
|
|
841
|
-
return ErrInvalidLength
|
|
842
|
-
}
|
|
843
|
-
postIndex := iNdEx + intStringLen
|
|
844
|
-
if postIndex < 0 {
|
|
845
|
-
return ErrInvalidLength
|
|
846
|
-
}
|
|
847
|
-
if postIndex > l {
|
|
848
|
-
return io.ErrUnexpectedEOF
|
|
849
|
-
}
|
|
850
|
-
m.Error = string(dAtA[iNdEx:postIndex])
|
|
851
|
-
iNdEx = postIndex
|
|
679
|
+
m.DataIsZero = bool(v != 0)
|
|
852
680
|
default:
|
|
853
681
|
iNdEx = preIndex
|
|
854
682
|
skippy, err := skip(dAtA[iNdEx:])
|
|
@@ -935,6 +763,26 @@ func (m *CallData) UnmarshalVT(dAtA []byte) error {
|
|
|
935
763
|
}
|
|
936
764
|
iNdEx = postIndex
|
|
937
765
|
case 2:
|
|
766
|
+
if wireType != 0 {
|
|
767
|
+
return fmt.Errorf("proto: wrong wireType = %d for field DataIsZero", wireType)
|
|
768
|
+
}
|
|
769
|
+
var v int
|
|
770
|
+
for shift := uint(0); ; shift += 7 {
|
|
771
|
+
if shift >= 64 {
|
|
772
|
+
return ErrIntOverflow
|
|
773
|
+
}
|
|
774
|
+
if iNdEx >= l {
|
|
775
|
+
return io.ErrUnexpectedEOF
|
|
776
|
+
}
|
|
777
|
+
b := dAtA[iNdEx]
|
|
778
|
+
iNdEx++
|
|
779
|
+
v |= int(b&0x7F) << shift
|
|
780
|
+
if b < 0x80 {
|
|
781
|
+
break
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
m.DataIsZero = bool(v != 0)
|
|
785
|
+
case 3:
|
|
938
786
|
if wireType != 0 {
|
|
939
787
|
return fmt.Errorf("proto: wrong wireType = %d for field Complete", wireType)
|
|
940
788
|
}
|
|
@@ -954,7 +802,7 @@ func (m *CallData) UnmarshalVT(dAtA []byte) error {
|
|
|
954
802
|
}
|
|
955
803
|
}
|
|
956
804
|
m.Complete = bool(v != 0)
|
|
957
|
-
case
|
|
805
|
+
case 4:
|
|
958
806
|
if wireType != 2 {
|
|
959
807
|
return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType)
|
|
960
808
|
}
|
package/srpc/server-rpc.go
CHANGED
|
@@ -66,8 +66,6 @@ func (r *ServerRPC) HandlePacket(msg *Packet) error {
|
|
|
66
66
|
return r.HandleCallStart(b.CallStart)
|
|
67
67
|
case *Packet_CallData:
|
|
68
68
|
return r.HandleCallData(b.CallData)
|
|
69
|
-
case *Packet_CallStartResp:
|
|
70
|
-
return r.HandleCallStartResp(b.CallStartResp)
|
|
71
69
|
default:
|
|
72
70
|
return nil
|
|
73
71
|
}
|
|
@@ -85,7 +83,10 @@ func (r *ServerRPC) HandleCallStart(pkt *CallStart) error {
|
|
|
85
83
|
r.method, r.service = pkt.GetRpcMethod(), pkt.GetRpcService()
|
|
86
84
|
|
|
87
85
|
// process first data packet, if included
|
|
88
|
-
if data := pkt.GetData(); len(data) != 0 {
|
|
86
|
+
if data := pkt.GetData(); len(data) != 0 || pkt.GetDataIsZero() {
|
|
87
|
+
if data == nil {
|
|
88
|
+
data = []byte{}
|
|
89
|
+
}
|
|
89
90
|
select {
|
|
90
91
|
case r.dataCh <- data:
|
|
91
92
|
default:
|
|
@@ -106,7 +107,7 @@ func (r *ServerRPC) HandleCallData(pkt *CallData) error {
|
|
|
106
107
|
return ErrCompleted
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
if data := pkt.GetData(); len(data) != 0 {
|
|
110
|
+
if data := pkt.GetData(); len(data) != 0 || pkt.GetDataIsZero() {
|
|
110
111
|
select {
|
|
111
112
|
case <-r.ctx.Done():
|
|
112
113
|
return context.Canceled
|
|
@@ -128,12 +129,6 @@ func (r *ServerRPC) HandleCallData(pkt *CallData) error {
|
|
|
128
129
|
return nil
|
|
129
130
|
}
|
|
130
131
|
|
|
131
|
-
// HandleCallStartResp handles the CallStartResp packet.
|
|
132
|
-
func (r *ServerRPC) HandleCallStartResp(resp *CallStartResp) error {
|
|
133
|
-
// client-side calls not supported
|
|
134
|
-
return errors.Wrap(ErrUnrecognizedPacket, "call start resp packet unexpected")
|
|
135
|
-
}
|
|
136
|
-
|
|
137
132
|
// invoke invokes the RPC after CallStart is received.
|
|
138
133
|
func (r *ServerRPC) invokeRPC() {
|
|
139
134
|
// ctx := r.ctx
|