starpc 0.10.6 → 0.10.8
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/README.md +19 -8
- package/dist/echo/echo.pb.d.ts +5 -5
- package/dist/echo/echo.pb.js +20 -20
- package/dist/rpcstream/rpcstream.pb.d.ts +7 -7
- package/dist/rpcstream/rpcstream.pb.js +39 -64
- package/dist/srpc/rpcproto.pb.d.ts +6 -6
- package/dist/srpc/rpcproto.pb.js +38 -75
- package/e2e/e2e_test.go +0 -7
- package/echo/echo.pb.ts +88 -144
- package/go.mod +9 -10
- package/go.sum +19 -21
- package/package.json +1 -1
- package/srpc/handler.go +11 -4
- package/srpc/mux.go +40 -4
- package/srpc/muxed-conn.go +7 -2
- package/srpc/rpcproto.pb.ts +183 -273
- package/srpc/rwc-conn.go +229 -0
- package/srpc/server-rpc.go +6 -6
- package/srpc/server.go +8 -8
package/dist/srpc/rpcproto.pb.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import Long from
|
|
3
|
-
import _m0 from
|
|
4
|
-
export const protobufPackage =
|
|
2
|
+
import Long from "long";
|
|
3
|
+
import _m0 from "protobufjs/minimal.js";
|
|
4
|
+
export const protobufPackage = "srpc";
|
|
5
5
|
function createBasePacket() {
|
|
6
6
|
return { body: undefined };
|
|
7
7
|
}
|
|
8
8
|
export const Packet = {
|
|
9
9
|
encode(message, writer = _m0.Writer.create()) {
|
|
10
|
-
if (message.body?.$case ===
|
|
10
|
+
if (message.body?.$case === "callStart") {
|
|
11
11
|
CallStart.encode(message.body.callStart, writer.uint32(10).fork()).ldelim();
|
|
12
12
|
}
|
|
13
|
-
if (message.body?.$case ===
|
|
13
|
+
if (message.body?.$case === "callData") {
|
|
14
14
|
CallData.encode(message.body.callData, writer.uint32(18).fork()).ldelim();
|
|
15
15
|
}
|
|
16
16
|
return writer;
|
|
@@ -23,16 +23,10 @@ export const Packet = {
|
|
|
23
23
|
const tag = reader.uint32();
|
|
24
24
|
switch (tag >>> 3) {
|
|
25
25
|
case 1:
|
|
26
|
-
message.body = {
|
|
27
|
-
$case: 'callStart',
|
|
28
|
-
callStart: CallStart.decode(reader, reader.uint32()),
|
|
29
|
-
};
|
|
26
|
+
message.body = { $case: "callStart", callStart: CallStart.decode(reader, reader.uint32()) };
|
|
30
27
|
break;
|
|
31
28
|
case 2:
|
|
32
|
-
message.body = {
|
|
33
|
-
$case: 'callData',
|
|
34
|
-
callData: CallData.decode(reader, reader.uint32()),
|
|
35
|
-
};
|
|
29
|
+
message.body = { $case: "callData", callData: CallData.decode(reader, reader.uint32()) };
|
|
36
30
|
break;
|
|
37
31
|
default:
|
|
38
32
|
reader.skipType(tag & 7);
|
|
@@ -72,62 +66,40 @@ export const Packet = {
|
|
|
72
66
|
fromJSON(object) {
|
|
73
67
|
return {
|
|
74
68
|
body: isSet(object.callStart)
|
|
75
|
-
? {
|
|
76
|
-
$case: 'callStart',
|
|
77
|
-
callStart: CallStart.fromJSON(object.callStart),
|
|
78
|
-
}
|
|
69
|
+
? { $case: "callStart", callStart: CallStart.fromJSON(object.callStart) }
|
|
79
70
|
: isSet(object.callData)
|
|
80
|
-
? { $case:
|
|
71
|
+
? { $case: "callData", callData: CallData.fromJSON(object.callData) }
|
|
81
72
|
: undefined,
|
|
82
73
|
};
|
|
83
74
|
},
|
|
84
75
|
toJSON(message) {
|
|
85
76
|
const obj = {};
|
|
86
|
-
message.body?.$case ===
|
|
87
|
-
(obj.callStart = message.body?.callStart
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
message.body?.$case === 'callData' &&
|
|
91
|
-
(obj.callData = message.body?.callData
|
|
92
|
-
? CallData.toJSON(message.body?.callData)
|
|
93
|
-
: undefined);
|
|
77
|
+
message.body?.$case === "callStart" &&
|
|
78
|
+
(obj.callStart = message.body?.callStart ? CallStart.toJSON(message.body?.callStart) : undefined);
|
|
79
|
+
message.body?.$case === "callData" &&
|
|
80
|
+
(obj.callData = message.body?.callData ? CallData.toJSON(message.body?.callData) : undefined);
|
|
94
81
|
return obj;
|
|
95
82
|
},
|
|
96
83
|
fromPartial(object) {
|
|
97
84
|
const message = createBasePacket();
|
|
98
|
-
if (object.body?.$case ===
|
|
99
|
-
|
|
100
|
-
object.body?.callStart !== null) {
|
|
101
|
-
message.body = {
|
|
102
|
-
$case: 'callStart',
|
|
103
|
-
callStart: CallStart.fromPartial(object.body.callStart),
|
|
104
|
-
};
|
|
85
|
+
if (object.body?.$case === "callStart" && object.body?.callStart !== undefined && object.body?.callStart !== null) {
|
|
86
|
+
message.body = { $case: "callStart", callStart: CallStart.fromPartial(object.body.callStart) };
|
|
105
87
|
}
|
|
106
|
-
if (object.body?.$case ===
|
|
107
|
-
|
|
108
|
-
object.body?.callData !== null) {
|
|
109
|
-
message.body = {
|
|
110
|
-
$case: 'callData',
|
|
111
|
-
callData: CallData.fromPartial(object.body.callData),
|
|
112
|
-
};
|
|
88
|
+
if (object.body?.$case === "callData" && object.body?.callData !== undefined && object.body?.callData !== null) {
|
|
89
|
+
message.body = { $case: "callData", callData: CallData.fromPartial(object.body.callData) };
|
|
113
90
|
}
|
|
114
91
|
return message;
|
|
115
92
|
},
|
|
116
93
|
};
|
|
117
94
|
function createBaseCallStart() {
|
|
118
|
-
return {
|
|
119
|
-
rpcService: '',
|
|
120
|
-
rpcMethod: '',
|
|
121
|
-
data: new Uint8Array(),
|
|
122
|
-
dataIsZero: false,
|
|
123
|
-
};
|
|
95
|
+
return { rpcService: "", rpcMethod: "", data: new Uint8Array(), dataIsZero: false };
|
|
124
96
|
}
|
|
125
97
|
export const CallStart = {
|
|
126
98
|
encode(message, writer = _m0.Writer.create()) {
|
|
127
|
-
if (message.rpcService !==
|
|
99
|
+
if (message.rpcService !== "") {
|
|
128
100
|
writer.uint32(10).string(message.rpcService);
|
|
129
101
|
}
|
|
130
|
-
if (message.rpcMethod !==
|
|
102
|
+
if (message.rpcMethod !== "") {
|
|
131
103
|
writer.uint32(18).string(message.rpcMethod);
|
|
132
104
|
}
|
|
133
105
|
if (message.data.length !== 0) {
|
|
@@ -194,11 +166,9 @@ export const CallStart = {
|
|
|
194
166
|
},
|
|
195
167
|
fromJSON(object) {
|
|
196
168
|
return {
|
|
197
|
-
rpcService: isSet(object.rpcService) ? String(object.rpcService) :
|
|
198
|
-
rpcMethod: isSet(object.rpcMethod) ? String(object.rpcMethod) :
|
|
199
|
-
data: isSet(object.data)
|
|
200
|
-
? bytesFromBase64(object.data)
|
|
201
|
-
: new Uint8Array(),
|
|
169
|
+
rpcService: isSet(object.rpcService) ? String(object.rpcService) : "",
|
|
170
|
+
rpcMethod: isSet(object.rpcMethod) ? String(object.rpcMethod) : "",
|
|
171
|
+
data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(),
|
|
202
172
|
dataIsZero: isSet(object.dataIsZero) ? Boolean(object.dataIsZero) : false,
|
|
203
173
|
};
|
|
204
174
|
},
|
|
@@ -213,20 +183,15 @@ export const CallStart = {
|
|
|
213
183
|
},
|
|
214
184
|
fromPartial(object) {
|
|
215
185
|
const message = createBaseCallStart();
|
|
216
|
-
message.rpcService = object.rpcService ??
|
|
217
|
-
message.rpcMethod = object.rpcMethod ??
|
|
186
|
+
message.rpcService = object.rpcService ?? "";
|
|
187
|
+
message.rpcMethod = object.rpcMethod ?? "";
|
|
218
188
|
message.data = object.data ?? new Uint8Array();
|
|
219
189
|
message.dataIsZero = object.dataIsZero ?? false;
|
|
220
190
|
return message;
|
|
221
191
|
},
|
|
222
192
|
};
|
|
223
193
|
function createBaseCallData() {
|
|
224
|
-
return {
|
|
225
|
-
data: new Uint8Array(),
|
|
226
|
-
dataIsZero: false,
|
|
227
|
-
complete: false,
|
|
228
|
-
error: '',
|
|
229
|
-
};
|
|
194
|
+
return { data: new Uint8Array(), dataIsZero: false, complete: false, error: "" };
|
|
230
195
|
}
|
|
231
196
|
export const CallData = {
|
|
232
197
|
encode(message, writer = _m0.Writer.create()) {
|
|
@@ -239,7 +204,7 @@ export const CallData = {
|
|
|
239
204
|
if (message.complete === true) {
|
|
240
205
|
writer.uint32(24).bool(message.complete);
|
|
241
206
|
}
|
|
242
|
-
if (message.error !==
|
|
207
|
+
if (message.error !== "") {
|
|
243
208
|
writer.uint32(34).string(message.error);
|
|
244
209
|
}
|
|
245
210
|
return writer;
|
|
@@ -300,12 +265,10 @@ export const CallData = {
|
|
|
300
265
|
},
|
|
301
266
|
fromJSON(object) {
|
|
302
267
|
return {
|
|
303
|
-
data: isSet(object.data)
|
|
304
|
-
? bytesFromBase64(object.data)
|
|
305
|
-
: new Uint8Array(),
|
|
268
|
+
data: isSet(object.data) ? bytesFromBase64(object.data) : new Uint8Array(),
|
|
306
269
|
dataIsZero: isSet(object.dataIsZero) ? Boolean(object.dataIsZero) : false,
|
|
307
270
|
complete: isSet(object.complete) ? Boolean(object.complete) : false,
|
|
308
|
-
error: isSet(object.error) ? String(object.error) :
|
|
271
|
+
error: isSet(object.error) ? String(object.error) : "",
|
|
309
272
|
};
|
|
310
273
|
},
|
|
311
274
|
toJSON(message) {
|
|
@@ -322,28 +285,28 @@ export const CallData = {
|
|
|
322
285
|
message.data = object.data ?? new Uint8Array();
|
|
323
286
|
message.dataIsZero = object.dataIsZero ?? false;
|
|
324
287
|
message.complete = object.complete ?? false;
|
|
325
|
-
message.error = object.error ??
|
|
288
|
+
message.error = object.error ?? "";
|
|
326
289
|
return message;
|
|
327
290
|
},
|
|
328
291
|
};
|
|
329
292
|
var globalThis = (() => {
|
|
330
|
-
if (typeof globalThis !==
|
|
293
|
+
if (typeof globalThis !== "undefined") {
|
|
331
294
|
return globalThis;
|
|
332
295
|
}
|
|
333
|
-
if (typeof self !==
|
|
296
|
+
if (typeof self !== "undefined") {
|
|
334
297
|
return self;
|
|
335
298
|
}
|
|
336
|
-
if (typeof window !==
|
|
299
|
+
if (typeof window !== "undefined") {
|
|
337
300
|
return window;
|
|
338
301
|
}
|
|
339
|
-
if (typeof global !==
|
|
302
|
+
if (typeof global !== "undefined") {
|
|
340
303
|
return global;
|
|
341
304
|
}
|
|
342
|
-
throw
|
|
305
|
+
throw "Unable to locate global object";
|
|
343
306
|
})();
|
|
344
307
|
function bytesFromBase64(b64) {
|
|
345
308
|
if (globalThis.Buffer) {
|
|
346
|
-
return Uint8Array.from(globalThis.Buffer.from(b64,
|
|
309
|
+
return Uint8Array.from(globalThis.Buffer.from(b64, "base64"));
|
|
347
310
|
}
|
|
348
311
|
else {
|
|
349
312
|
const bin = globalThis.atob(b64);
|
|
@@ -356,14 +319,14 @@ function bytesFromBase64(b64) {
|
|
|
356
319
|
}
|
|
357
320
|
function base64FromBytes(arr) {
|
|
358
321
|
if (globalThis.Buffer) {
|
|
359
|
-
return globalThis.Buffer.from(arr).toString(
|
|
322
|
+
return globalThis.Buffer.from(arr).toString("base64");
|
|
360
323
|
}
|
|
361
324
|
else {
|
|
362
325
|
const bin = [];
|
|
363
326
|
arr.forEach((byte) => {
|
|
364
327
|
bin.push(String.fromCharCode(byte));
|
|
365
328
|
});
|
|
366
|
-
return globalThis.btoa(bin.join(
|
|
329
|
+
return globalThis.btoa(bin.join(""));
|
|
367
330
|
}
|
|
368
331
|
}
|
|
369
332
|
if (_m0.util.Long !== Long) {
|
package/e2e/e2e_test.go
CHANGED
|
@@ -171,13 +171,6 @@ func TestE2E_BidiStream(t *testing.T) {
|
|
|
171
171
|
if msg.GetBody() != expected {
|
|
172
172
|
t.Fatalf("expected %q got %q", expected, msg.GetBody())
|
|
173
173
|
}
|
|
174
|
-
msg, err = strm.Recv()
|
|
175
|
-
if err != nil {
|
|
176
|
-
t.Fatal(err.Error())
|
|
177
|
-
}
|
|
178
|
-
if msg.GetBody() != clientExpected {
|
|
179
|
-
t.Fatalf("expected %q got %q", clientExpected, msg.GetBody())
|
|
180
|
-
}
|
|
181
174
|
// expect no error closing
|
|
182
175
|
return strm.Close()
|
|
183
176
|
})
|
package/echo/echo.pb.ts
CHANGED
|
@@ -1,60 +1,57 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
import Long from
|
|
3
|
-
import _m0 from
|
|
4
|
-
import { RpcStreamPacket } from
|
|
2
|
+
import Long from "long";
|
|
3
|
+
import _m0 from "protobufjs/minimal.js";
|
|
4
|
+
import { RpcStreamPacket } from "../rpcstream/rpcstream.pb.js";
|
|
5
5
|
|
|
6
|
-
export const protobufPackage =
|
|
6
|
+
export const protobufPackage = "echo";
|
|
7
7
|
|
|
8
8
|
/** EchoMsg is the message body for Echo. */
|
|
9
9
|
export interface EchoMsg {
|
|
10
|
-
body: string
|
|
10
|
+
body: string;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
function createBaseEchoMsg(): EchoMsg {
|
|
14
|
-
return { body:
|
|
14
|
+
return { body: "" };
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
export const EchoMsg = {
|
|
18
|
-
encode(
|
|
19
|
-
message
|
|
20
|
-
|
|
21
|
-
): _m0.Writer {
|
|
22
|
-
if (message.body !== '') {
|
|
23
|
-
writer.uint32(10).string(message.body)
|
|
18
|
+
encode(message: EchoMsg, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
|
|
19
|
+
if (message.body !== "") {
|
|
20
|
+
writer.uint32(10).string(message.body);
|
|
24
21
|
}
|
|
25
|
-
return writer
|
|
22
|
+
return writer;
|
|
26
23
|
},
|
|
27
24
|
|
|
28
25
|
decode(input: _m0.Reader | Uint8Array, length?: number): EchoMsg {
|
|
29
|
-
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input)
|
|
30
|
-
let end = length === undefined ? reader.len : reader.pos + length
|
|
31
|
-
const message = createBaseEchoMsg()
|
|
26
|
+
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
|
|
27
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
28
|
+
const message = createBaseEchoMsg();
|
|
32
29
|
while (reader.pos < end) {
|
|
33
|
-
const tag = reader.uint32()
|
|
30
|
+
const tag = reader.uint32();
|
|
34
31
|
switch (tag >>> 3) {
|
|
35
32
|
case 1:
|
|
36
|
-
message.body = reader.string()
|
|
37
|
-
break
|
|
33
|
+
message.body = reader.string();
|
|
34
|
+
break;
|
|
38
35
|
default:
|
|
39
|
-
reader.skipType(tag & 7)
|
|
40
|
-
break
|
|
36
|
+
reader.skipType(tag & 7);
|
|
37
|
+
break;
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
return message
|
|
40
|
+
return message;
|
|
44
41
|
},
|
|
45
42
|
|
|
46
43
|
// encodeTransform encodes a source of message objects.
|
|
47
44
|
// Transform<EchoMsg, Uint8Array>
|
|
48
45
|
async *encodeTransform(
|
|
49
|
-
source: AsyncIterable<EchoMsg | EchoMsg[]> | Iterable<EchoMsg | EchoMsg[]
|
|
46
|
+
source: AsyncIterable<EchoMsg | EchoMsg[]> | Iterable<EchoMsg | EchoMsg[]>,
|
|
50
47
|
): AsyncIterable<Uint8Array> {
|
|
51
48
|
for await (const pkt of source) {
|
|
52
49
|
if (Array.isArray(pkt)) {
|
|
53
50
|
for (const p of pkt) {
|
|
54
|
-
yield* [EchoMsg.encode(p).finish()]
|
|
51
|
+
yield* [EchoMsg.encode(p).finish()];
|
|
55
52
|
}
|
|
56
53
|
} else {
|
|
57
|
-
yield* [EchoMsg.encode(pkt).finish()]
|
|
54
|
+
yield* [EchoMsg.encode(pkt).finish()];
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
},
|
|
@@ -62,122 +59,100 @@ export const EchoMsg = {
|
|
|
62
59
|
// decodeTransform decodes a source of encoded messages.
|
|
63
60
|
// Transform<Uint8Array, EchoMsg>
|
|
64
61
|
async *decodeTransform(
|
|
65
|
-
source:
|
|
66
|
-
| AsyncIterable<Uint8Array | Uint8Array[]>
|
|
67
|
-
| Iterable<Uint8Array | Uint8Array[]>
|
|
62
|
+
source: AsyncIterable<Uint8Array | Uint8Array[]> | Iterable<Uint8Array | Uint8Array[]>,
|
|
68
63
|
): AsyncIterable<EchoMsg> {
|
|
69
64
|
for await (const pkt of source) {
|
|
70
65
|
if (Array.isArray(pkt)) {
|
|
71
66
|
for (const p of pkt) {
|
|
72
|
-
yield* [EchoMsg.decode(p)]
|
|
67
|
+
yield* [EchoMsg.decode(p)];
|
|
73
68
|
}
|
|
74
69
|
} else {
|
|
75
|
-
yield* [EchoMsg.decode(pkt)]
|
|
70
|
+
yield* [EchoMsg.decode(pkt)];
|
|
76
71
|
}
|
|
77
72
|
}
|
|
78
73
|
},
|
|
79
74
|
|
|
80
75
|
fromJSON(object: any): EchoMsg {
|
|
81
|
-
return { body: isSet(object.body) ? String(object.body) :
|
|
76
|
+
return { body: isSet(object.body) ? String(object.body) : "" };
|
|
82
77
|
},
|
|
83
78
|
|
|
84
79
|
toJSON(message: EchoMsg): unknown {
|
|
85
|
-
const obj: any = {}
|
|
86
|
-
message.body !== undefined && (obj.body = message.body)
|
|
87
|
-
return obj
|
|
80
|
+
const obj: any = {};
|
|
81
|
+
message.body !== undefined && (obj.body = message.body);
|
|
82
|
+
return obj;
|
|
88
83
|
},
|
|
89
84
|
|
|
90
85
|
fromPartial<I extends Exact<DeepPartial<EchoMsg>, I>>(object: I): EchoMsg {
|
|
91
|
-
const message = createBaseEchoMsg()
|
|
92
|
-
message.body = object.body ??
|
|
93
|
-
return message
|
|
86
|
+
const message = createBaseEchoMsg();
|
|
87
|
+
message.body = object.body ?? "";
|
|
88
|
+
return message;
|
|
94
89
|
},
|
|
95
|
-
}
|
|
90
|
+
};
|
|
96
91
|
|
|
97
92
|
/** Echoer service returns the given message. */
|
|
98
93
|
export interface Echoer {
|
|
99
94
|
/** Echo returns the given message. */
|
|
100
|
-
Echo(request: EchoMsg): Promise<EchoMsg
|
|
95
|
+
Echo(request: EchoMsg): Promise<EchoMsg>;
|
|
101
96
|
/** EchoServerStream is an example of a server -> client one-way stream. */
|
|
102
|
-
EchoServerStream(request: EchoMsg): AsyncIterable<EchoMsg
|
|
97
|
+
EchoServerStream(request: EchoMsg): AsyncIterable<EchoMsg>;
|
|
103
98
|
/** EchoClientStream is an example of client->server one-way stream. */
|
|
104
|
-
EchoClientStream(request: AsyncIterable<EchoMsg>): Promise<EchoMsg
|
|
99
|
+
EchoClientStream(request: AsyncIterable<EchoMsg>): Promise<EchoMsg>;
|
|
105
100
|
/** EchoBidiStream is an example of a two-way stream. */
|
|
106
|
-
EchoBidiStream(request: AsyncIterable<EchoMsg>): AsyncIterable<EchoMsg
|
|
101
|
+
EchoBidiStream(request: AsyncIterable<EchoMsg>): AsyncIterable<EchoMsg>;
|
|
107
102
|
/** RpcStream opens a nested rpc call stream. */
|
|
108
|
-
RpcStream(
|
|
109
|
-
request: AsyncIterable<RpcStreamPacket>
|
|
110
|
-
): AsyncIterable<RpcStreamPacket>
|
|
103
|
+
RpcStream(request: AsyncIterable<RpcStreamPacket>): AsyncIterable<RpcStreamPacket>;
|
|
111
104
|
}
|
|
112
105
|
|
|
113
106
|
export class EchoerClientImpl implements Echoer {
|
|
114
|
-
private readonly rpc: Rpc
|
|
107
|
+
private readonly rpc: Rpc;
|
|
115
108
|
constructor(rpc: Rpc) {
|
|
116
|
-
this.rpc = rpc
|
|
117
|
-
this.Echo = this.Echo.bind(this)
|
|
118
|
-
this.EchoServerStream = this.EchoServerStream.bind(this)
|
|
119
|
-
this.EchoClientStream = this.EchoClientStream.bind(this)
|
|
120
|
-
this.EchoBidiStream = this.EchoBidiStream.bind(this)
|
|
121
|
-
this.RpcStream = this.RpcStream.bind(this)
|
|
109
|
+
this.rpc = rpc;
|
|
110
|
+
this.Echo = this.Echo.bind(this);
|
|
111
|
+
this.EchoServerStream = this.EchoServerStream.bind(this);
|
|
112
|
+
this.EchoClientStream = this.EchoClientStream.bind(this);
|
|
113
|
+
this.EchoBidiStream = this.EchoBidiStream.bind(this);
|
|
114
|
+
this.RpcStream = this.RpcStream.bind(this);
|
|
122
115
|
}
|
|
123
116
|
Echo(request: EchoMsg): Promise<EchoMsg> {
|
|
124
|
-
const data = EchoMsg.encode(request).finish()
|
|
125
|
-
const promise = this.rpc.request(
|
|
126
|
-
return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)))
|
|
117
|
+
const data = EchoMsg.encode(request).finish();
|
|
118
|
+
const promise = this.rpc.request("echo.Echoer", "Echo", data);
|
|
119
|
+
return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)));
|
|
127
120
|
}
|
|
128
121
|
|
|
129
122
|
EchoServerStream(request: EchoMsg): AsyncIterable<EchoMsg> {
|
|
130
|
-
const data = EchoMsg.encode(request).finish()
|
|
131
|
-
const result = this.rpc.serverStreamingRequest(
|
|
132
|
-
|
|
133
|
-
'EchoServerStream',
|
|
134
|
-
data
|
|
135
|
-
)
|
|
136
|
-
return EchoMsg.decodeTransform(result)
|
|
123
|
+
const data = EchoMsg.encode(request).finish();
|
|
124
|
+
const result = this.rpc.serverStreamingRequest("echo.Echoer", "EchoServerStream", data);
|
|
125
|
+
return EchoMsg.decodeTransform(result);
|
|
137
126
|
}
|
|
138
127
|
|
|
139
128
|
EchoClientStream(request: AsyncIterable<EchoMsg>): Promise<EchoMsg> {
|
|
140
|
-
const data = EchoMsg.encodeTransform(request)
|
|
141
|
-
const promise = this.rpc.clientStreamingRequest(
|
|
142
|
-
|
|
143
|
-
'EchoClientStream',
|
|
144
|
-
data
|
|
145
|
-
)
|
|
146
|
-
return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)))
|
|
129
|
+
const data = EchoMsg.encodeTransform(request);
|
|
130
|
+
const promise = this.rpc.clientStreamingRequest("echo.Echoer", "EchoClientStream", data);
|
|
131
|
+
return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)));
|
|
147
132
|
}
|
|
148
133
|
|
|
149
134
|
EchoBidiStream(request: AsyncIterable<EchoMsg>): AsyncIterable<EchoMsg> {
|
|
150
|
-
const data = EchoMsg.encodeTransform(request)
|
|
151
|
-
const result = this.rpc.bidirectionalStreamingRequest(
|
|
152
|
-
|
|
153
|
-
'EchoBidiStream',
|
|
154
|
-
data
|
|
155
|
-
)
|
|
156
|
-
return EchoMsg.decodeTransform(result)
|
|
135
|
+
const data = EchoMsg.encodeTransform(request);
|
|
136
|
+
const result = this.rpc.bidirectionalStreamingRequest("echo.Echoer", "EchoBidiStream", data);
|
|
137
|
+
return EchoMsg.decodeTransform(result);
|
|
157
138
|
}
|
|
158
139
|
|
|
159
|
-
RpcStream(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const result = this.rpc.bidirectionalStreamingRequest(
|
|
164
|
-
'echo.Echoer',
|
|
165
|
-
'RpcStream',
|
|
166
|
-
data
|
|
167
|
-
)
|
|
168
|
-
return RpcStreamPacket.decodeTransform(result)
|
|
140
|
+
RpcStream(request: AsyncIterable<RpcStreamPacket>): AsyncIterable<RpcStreamPacket> {
|
|
141
|
+
const data = RpcStreamPacket.encodeTransform(request);
|
|
142
|
+
const result = this.rpc.bidirectionalStreamingRequest("echo.Echoer", "RpcStream", data);
|
|
143
|
+
return RpcStreamPacket.decodeTransform(result);
|
|
169
144
|
}
|
|
170
145
|
}
|
|
171
146
|
|
|
172
147
|
/** Echoer service returns the given message. */
|
|
173
|
-
export type EchoerDefinition = typeof EchoerDefinition
|
|
148
|
+
export type EchoerDefinition = typeof EchoerDefinition;
|
|
174
149
|
export const EchoerDefinition = {
|
|
175
|
-
name:
|
|
176
|
-
fullName:
|
|
150
|
+
name: "Echoer",
|
|
151
|
+
fullName: "echo.Echoer",
|
|
177
152
|
methods: {
|
|
178
153
|
/** Echo returns the given message. */
|
|
179
154
|
echo: {
|
|
180
|
-
name:
|
|
155
|
+
name: "Echo",
|
|
181
156
|
requestType: EchoMsg,
|
|
182
157
|
requestStream: false,
|
|
183
158
|
responseType: EchoMsg,
|
|
@@ -186,7 +161,7 @@ export const EchoerDefinition = {
|
|
|
186
161
|
},
|
|
187
162
|
/** EchoServerStream is an example of a server -> client one-way stream. */
|
|
188
163
|
echoServerStream: {
|
|
189
|
-
name:
|
|
164
|
+
name: "EchoServerStream",
|
|
190
165
|
requestType: EchoMsg,
|
|
191
166
|
requestStream: false,
|
|
192
167
|
responseType: EchoMsg,
|
|
@@ -195,7 +170,7 @@ export const EchoerDefinition = {
|
|
|
195
170
|
},
|
|
196
171
|
/** EchoClientStream is an example of client->server one-way stream. */
|
|
197
172
|
echoClientStream: {
|
|
198
|
-
name:
|
|
173
|
+
name: "EchoClientStream",
|
|
199
174
|
requestType: EchoMsg,
|
|
200
175
|
requestStream: true,
|
|
201
176
|
responseType: EchoMsg,
|
|
@@ -204,7 +179,7 @@ export const EchoerDefinition = {
|
|
|
204
179
|
},
|
|
205
180
|
/** EchoBidiStream is an example of a two-way stream. */
|
|
206
181
|
echoBidiStream: {
|
|
207
|
-
name:
|
|
182
|
+
name: "EchoBidiStream",
|
|
208
183
|
requestType: EchoMsg,
|
|
209
184
|
requestStream: true,
|
|
210
185
|
responseType: EchoMsg,
|
|
@@ -213,7 +188,7 @@ export const EchoerDefinition = {
|
|
|
213
188
|
},
|
|
214
189
|
/** RpcStream opens a nested rpc call stream. */
|
|
215
190
|
rpcStream: {
|
|
216
|
-
name:
|
|
191
|
+
name: "RpcStream",
|
|
217
192
|
requestType: RpcStreamPacket,
|
|
218
193
|
requestStream: true,
|
|
219
194
|
responseType: RpcStreamPacket,
|
|
@@ -221,68 +196,37 @@ export const EchoerDefinition = {
|
|
|
221
196
|
options: {},
|
|
222
197
|
},
|
|
223
198
|
},
|
|
224
|
-
} as const
|
|
199
|
+
} as const;
|
|
225
200
|
|
|
226
201
|
interface Rpc {
|
|
227
|
-
request(
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
data: Uint8Array
|
|
231
|
-
): Promise<Uint8Array>
|
|
232
|
-
clientStreamingRequest(
|
|
233
|
-
service: string,
|
|
234
|
-
method: string,
|
|
235
|
-
data: AsyncIterable<Uint8Array>
|
|
236
|
-
): Promise<Uint8Array>
|
|
237
|
-
serverStreamingRequest(
|
|
238
|
-
service: string,
|
|
239
|
-
method: string,
|
|
240
|
-
data: Uint8Array
|
|
241
|
-
): AsyncIterable<Uint8Array>
|
|
202
|
+
request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
|
|
203
|
+
clientStreamingRequest(service: string, method: string, data: AsyncIterable<Uint8Array>): Promise<Uint8Array>;
|
|
204
|
+
serverStreamingRequest(service: string, method: string, data: Uint8Array): AsyncIterable<Uint8Array>;
|
|
242
205
|
bidirectionalStreamingRequest(
|
|
243
206
|
service: string,
|
|
244
207
|
method: string,
|
|
245
|
-
data: AsyncIterable<Uint8Array
|
|
246
|
-
): AsyncIterable<Uint8Array
|
|
208
|
+
data: AsyncIterable<Uint8Array>,
|
|
209
|
+
): AsyncIterable<Uint8Array>;
|
|
247
210
|
}
|
|
248
211
|
|
|
249
|
-
type Builtin =
|
|
250
|
-
| Date
|
|
251
|
-
| Function
|
|
252
|
-
| Uint8Array
|
|
253
|
-
| string
|
|
254
|
-
| number
|
|
255
|
-
| boolean
|
|
256
|
-
| undefined
|
|
212
|
+
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
257
213
|
|
|
258
|
-
export type DeepPartial<T> = T extends Builtin
|
|
259
|
-
? T
|
|
260
|
-
: T extends
|
|
261
|
-
|
|
262
|
-
: T extends
|
|
263
|
-
|
|
264
|
-
: T extends ReadonlyArray<infer U>
|
|
265
|
-
? ReadonlyArray<DeepPartial<U>>
|
|
266
|
-
: T extends { $case: string }
|
|
267
|
-
? { [K in keyof Omit<T, '$case'>]?: DeepPartial<T[K]> } & {
|
|
268
|
-
$case: T['$case']
|
|
269
|
-
}
|
|
270
|
-
: T extends {}
|
|
271
|
-
? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
272
|
-
: Partial<T>
|
|
214
|
+
export type DeepPartial<T> = T extends Builtin ? T
|
|
215
|
+
: T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>>
|
|
216
|
+
: T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
|
|
217
|
+
: T extends { $case: string } ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { $case: T["$case"] }
|
|
218
|
+
: T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
|
|
219
|
+
: Partial<T>;
|
|
273
220
|
|
|
274
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never
|
|
275
|
-
export type Exact<P, I extends P> = P extends Builtin
|
|
276
|
-
|
|
277
|
-
: P & { [K in keyof P]: Exact<P[K], I[K]> } & {
|
|
278
|
-
[K in Exclude<keyof I, KeysOfUnion<P>>]: never
|
|
279
|
-
}
|
|
221
|
+
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
222
|
+
export type Exact<P, I extends P> = P extends Builtin ? P
|
|
223
|
+
: P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
|
|
280
224
|
|
|
281
225
|
if (_m0.util.Long !== Long) {
|
|
282
|
-
_m0.util.Long = Long as any
|
|
283
|
-
_m0.configure()
|
|
226
|
+
_m0.util.Long = Long as any;
|
|
227
|
+
_m0.configure();
|
|
284
228
|
}
|
|
285
229
|
|
|
286
230
|
function isSet(value: any): boolean {
|
|
287
|
-
return value !== null && value !== undefined
|
|
231
|
+
return value !== null && value !== undefined;
|
|
288
232
|
}
|
package/go.mod
CHANGED
|
@@ -9,37 +9,36 @@ require (
|
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
require (
|
|
12
|
-
github.com/libp2p/go-libp2p v0.
|
|
13
|
-
github.com/libp2p/go-
|
|
14
|
-
github.com/libp2p/go-mplex v0.7.1-0.20220825125536-a00a1352b54f
|
|
12
|
+
github.com/libp2p/go-libp2p v0.23.2
|
|
13
|
+
github.com/libp2p/go-mplex v0.7.1-0.20220919134208-b0cc3e9c41a9
|
|
15
14
|
github.com/sirupsen/logrus v1.9.0
|
|
16
15
|
)
|
|
17
16
|
|
|
18
17
|
require (
|
|
19
18
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect
|
|
20
19
|
github.com/gogo/protobuf v1.3.2 // indirect
|
|
21
|
-
github.com/ipfs/go-cid v0.2
|
|
20
|
+
github.com/ipfs/go-cid v0.3.2 // indirect
|
|
22
21
|
github.com/ipfs/go-log/v2 v2.5.1 // indirect
|
|
23
|
-
github.com/klauspost/compress v1.15.
|
|
24
|
-
github.com/klauspost/cpuid/v2 v2.1.
|
|
22
|
+
github.com/klauspost/compress v1.15.10 // indirect
|
|
23
|
+
github.com/klauspost/cpuid/v2 v2.1.1 // indirect
|
|
25
24
|
github.com/libp2p/go-buffer-pool v0.1.0 // indirect
|
|
26
25
|
github.com/libp2p/go-openssl v0.1.0 // indirect
|
|
27
26
|
github.com/mattn/go-isatty v0.0.16 // indirect
|
|
28
27
|
github.com/mattn/go-pointer v0.0.1 // indirect
|
|
29
28
|
github.com/minio/sha256-simd v1.0.0 // indirect
|
|
30
29
|
github.com/mr-tron/base58 v1.2.0 // indirect
|
|
31
|
-
github.com/multiformats/go-base32 v0.0
|
|
30
|
+
github.com/multiformats/go-base32 v0.1.0 // indirect
|
|
32
31
|
github.com/multiformats/go-base36 v0.1.0 // indirect
|
|
33
|
-
github.com/multiformats/go-multiaddr v0.
|
|
32
|
+
github.com/multiformats/go-multiaddr v0.7.0 // indirect
|
|
34
33
|
github.com/multiformats/go-multibase v0.1.1 // indirect
|
|
35
|
-
github.com/multiformats/go-multicodec v0.
|
|
34
|
+
github.com/multiformats/go-multicodec v0.6.0 // indirect
|
|
36
35
|
github.com/multiformats/go-multihash v0.2.1 // indirect
|
|
37
36
|
github.com/multiformats/go-varint v0.0.6 // indirect
|
|
38
37
|
github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect
|
|
39
38
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
|
40
39
|
go.uber.org/atomic v1.10.0 // indirect
|
|
41
40
|
go.uber.org/multierr v1.8.0 // indirect
|
|
42
|
-
go.uber.org/zap v1.
|
|
41
|
+
go.uber.org/zap v1.23.0 // indirect
|
|
43
42
|
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
|
|
44
43
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
|
|
45
44
|
lukechampine.com/blake3 v1.1.7 // indirect
|