starpc 0.11.0 → 0.11.2

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.
@@ -1,16 +1,16 @@
1
1
  /* eslint-disable */
2
- import Long from 'long';
3
- import _m0 from 'protobufjs/minimal.js';
4
- export const protobufPackage = 'srpc';
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 === 'callStart') {
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 === 'callData') {
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: 'callData', callData: CallData.fromJSON(object.callData) }
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 === 'callStart' &&
87
- (obj.callStart = message.body?.callStart
88
- ? CallStart.toJSON(message.body?.callStart)
89
- : undefined);
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 === 'callStart' &&
99
- object.body?.callStart !== undefined &&
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 === 'callData' &&
107
- object.body?.callData !== undefined &&
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 !== 'undefined') {
293
+ if (typeof globalThis !== "undefined") {
331
294
  return globalThis;
332
295
  }
333
- if (typeof self !== 'undefined') {
296
+ if (typeof self !== "undefined") {
334
297
  return self;
335
298
  }
336
- if (typeof window !== 'undefined') {
299
+ if (typeof window !== "undefined") {
337
300
  return window;
338
301
  }
339
- if (typeof global !== 'undefined') {
302
+ if (typeof global !== "undefined") {
340
303
  return global;
341
304
  }
342
- throw 'Unable to locate global object';
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, 'base64'));
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('base64');
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/echo/echo.pb.ts CHANGED
@@ -1,60 +1,57 @@
1
1
  /* eslint-disable */
2
- import Long from 'long'
3
- import _m0 from 'protobufjs/minimal.js'
4
- import { RpcStreamPacket } from '../rpcstream/rpcstream.pb.js'
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 = 'echo'
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: EchoMsg,
20
- writer: _m0.Writer = _m0.Writer.create()
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,102 @@ 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
115
- 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)
107
+ private readonly rpc: Rpc;
108
+ private readonly service: string;
109
+ constructor(rpc: Rpc, service?: string) {
110
+ this.service = service || "echo.Echoer";
111
+ this.rpc = rpc;
112
+ this.Echo = this.Echo.bind(this);
113
+ this.EchoServerStream = this.EchoServerStream.bind(this);
114
+ this.EchoClientStream = this.EchoClientStream.bind(this);
115
+ this.EchoBidiStream = this.EchoBidiStream.bind(this);
116
+ this.RpcStream = this.RpcStream.bind(this);
122
117
  }
123
118
  Echo(request: EchoMsg): Promise<EchoMsg> {
124
- const data = EchoMsg.encode(request).finish()
125
- const promise = this.rpc.request('echo.Echoer', 'Echo', data)
126
- return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)))
119
+ const data = EchoMsg.encode(request).finish();
120
+ const promise = this.rpc.request(this.service, "Echo", data);
121
+ return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)));
127
122
  }
128
123
 
129
124
  EchoServerStream(request: EchoMsg): AsyncIterable<EchoMsg> {
130
- const data = EchoMsg.encode(request).finish()
131
- const result = this.rpc.serverStreamingRequest(
132
- 'echo.Echoer',
133
- 'EchoServerStream',
134
- data
135
- )
136
- return EchoMsg.decodeTransform(result)
125
+ const data = EchoMsg.encode(request).finish();
126
+ const result = this.rpc.serverStreamingRequest(this.service, "EchoServerStream", data);
127
+ return EchoMsg.decodeTransform(result);
137
128
  }
138
129
 
139
130
  EchoClientStream(request: AsyncIterable<EchoMsg>): Promise<EchoMsg> {
140
- const data = EchoMsg.encodeTransform(request)
141
- const promise = this.rpc.clientStreamingRequest(
142
- 'echo.Echoer',
143
- 'EchoClientStream',
144
- data
145
- )
146
- return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)))
131
+ const data = EchoMsg.encodeTransform(request);
132
+ const promise = this.rpc.clientStreamingRequest(this.service, "EchoClientStream", data);
133
+ return promise.then((data) => EchoMsg.decode(new _m0.Reader(data)));
147
134
  }
148
135
 
149
136
  EchoBidiStream(request: AsyncIterable<EchoMsg>): AsyncIterable<EchoMsg> {
150
- const data = EchoMsg.encodeTransform(request)
151
- const result = this.rpc.bidirectionalStreamingRequest(
152
- 'echo.Echoer',
153
- 'EchoBidiStream',
154
- data
155
- )
156
- return EchoMsg.decodeTransform(result)
137
+ const data = EchoMsg.encodeTransform(request);
138
+ const result = this.rpc.bidirectionalStreamingRequest(this.service, "EchoBidiStream", data);
139
+ return EchoMsg.decodeTransform(result);
157
140
  }
158
141
 
159
- RpcStream(
160
- request: AsyncIterable<RpcStreamPacket>
161
- ): AsyncIterable<RpcStreamPacket> {
162
- const data = RpcStreamPacket.encodeTransform(request)
163
- const result = this.rpc.bidirectionalStreamingRequest(
164
- 'echo.Echoer',
165
- 'RpcStream',
166
- data
167
- )
168
- return RpcStreamPacket.decodeTransform(result)
142
+ RpcStream(request: AsyncIterable<RpcStreamPacket>): AsyncIterable<RpcStreamPacket> {
143
+ const data = RpcStreamPacket.encodeTransform(request);
144
+ const result = this.rpc.bidirectionalStreamingRequest(this.service, "RpcStream", data);
145
+ return RpcStreamPacket.decodeTransform(result);
169
146
  }
170
147
  }
171
148
 
172
149
  /** Echoer service returns the given message. */
173
- export type EchoerDefinition = typeof EchoerDefinition
150
+ export type EchoerDefinition = typeof EchoerDefinition;
174
151
  export const EchoerDefinition = {
175
- name: 'Echoer',
176
- fullName: 'echo.Echoer',
152
+ name: "Echoer",
153
+ fullName: "echo.Echoer",
177
154
  methods: {
178
155
  /** Echo returns the given message. */
179
156
  echo: {
180
- name: 'Echo',
157
+ name: "Echo",
181
158
  requestType: EchoMsg,
182
159
  requestStream: false,
183
160
  responseType: EchoMsg,
@@ -186,7 +163,7 @@ export const EchoerDefinition = {
186
163
  },
187
164
  /** EchoServerStream is an example of a server -> client one-way stream. */
188
165
  echoServerStream: {
189
- name: 'EchoServerStream',
166
+ name: "EchoServerStream",
190
167
  requestType: EchoMsg,
191
168
  requestStream: false,
192
169
  responseType: EchoMsg,
@@ -195,7 +172,7 @@ export const EchoerDefinition = {
195
172
  },
196
173
  /** EchoClientStream is an example of client->server one-way stream. */
197
174
  echoClientStream: {
198
- name: 'EchoClientStream',
175
+ name: "EchoClientStream",
199
176
  requestType: EchoMsg,
200
177
  requestStream: true,
201
178
  responseType: EchoMsg,
@@ -204,7 +181,7 @@ export const EchoerDefinition = {
204
181
  },
205
182
  /** EchoBidiStream is an example of a two-way stream. */
206
183
  echoBidiStream: {
207
- name: 'EchoBidiStream',
184
+ name: "EchoBidiStream",
208
185
  requestType: EchoMsg,
209
186
  requestStream: true,
210
187
  responseType: EchoMsg,
@@ -213,7 +190,7 @@ export const EchoerDefinition = {
213
190
  },
214
191
  /** RpcStream opens a nested rpc call stream. */
215
192
  rpcStream: {
216
- name: 'RpcStream',
193
+ name: "RpcStream",
217
194
  requestType: RpcStreamPacket,
218
195
  requestStream: true,
219
196
  responseType: RpcStreamPacket,
@@ -221,68 +198,37 @@ export const EchoerDefinition = {
221
198
  options: {},
222
199
  },
223
200
  },
224
- } as const
201
+ } as const;
225
202
 
226
203
  interface Rpc {
227
- request(
228
- service: string,
229
- method: string,
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>
204
+ request(service: string, method: string, data: Uint8Array): Promise<Uint8Array>;
205
+ clientStreamingRequest(service: string, method: string, data: AsyncIterable<Uint8Array>): Promise<Uint8Array>;
206
+ serverStreamingRequest(service: string, method: string, data: Uint8Array): AsyncIterable<Uint8Array>;
242
207
  bidirectionalStreamingRequest(
243
208
  service: string,
244
209
  method: string,
245
- data: AsyncIterable<Uint8Array>
246
- ): AsyncIterable<Uint8Array>
210
+ data: AsyncIterable<Uint8Array>,
211
+ ): AsyncIterable<Uint8Array>;
247
212
  }
248
213
 
249
- type Builtin =
250
- | Date
251
- | Function
252
- | Uint8Array
253
- | string
254
- | number
255
- | boolean
256
- | undefined
214
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
257
215
 
258
- export type DeepPartial<T> = T extends Builtin
259
- ? T
260
- : T extends Long
261
- ? string | number | Long
262
- : T extends Array<infer U>
263
- ? Array<DeepPartial<U>>
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>
216
+ export type DeepPartial<T> = T extends Builtin ? T
217
+ : T extends Long ? string | number | Long : T extends Array<infer U> ? Array<DeepPartial<U>>
218
+ : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>>
219
+ : T extends { $case: string } ? { [K in keyof Omit<T, "$case">]?: DeepPartial<T[K]> } & { $case: T["$case"] }
220
+ : T extends {} ? { [K in keyof T]?: DeepPartial<T[K]> }
221
+ : Partial<T>;
273
222
 
274
- type KeysOfUnion<T> = T extends T ? keyof T : never
275
- export type Exact<P, I extends P> = P extends Builtin
276
- ? P
277
- : P & { [K in keyof P]: Exact<P[K], I[K]> } & {
278
- [K in Exclude<keyof I, KeysOfUnion<P>>]: never
279
- }
223
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
224
+ export type Exact<P, I extends P> = P extends Builtin ? P
225
+ : P & { [K in keyof P]: Exact<P[K], I[K]> } & { [K in Exclude<keyof I, KeysOfUnion<P>>]: never };
280
226
 
281
227
  if (_m0.util.Long !== Long) {
282
- _m0.util.Long = Long as any
283
- _m0.configure()
228
+ _m0.util.Long = Long as any;
229
+ _m0.configure();
284
230
  }
285
231
 
286
232
  function isSet(value: any): boolean {
287
- return value !== null && value !== undefined
233
+ return value !== null && value !== undefined;
288
234
  }
@@ -22,18 +22,26 @@ type SRPCEchoerClient interface {
22
22
  }
23
23
 
24
24
  type srpcEchoerClient struct {
25
- cc srpc.Client
25
+ cc srpc.Client
26
+ serviceID string
26
27
  }
27
28
 
28
29
  func NewSRPCEchoerClient(cc srpc.Client) SRPCEchoerClient {
29
- return &srpcEchoerClient{cc}
30
+ return &srpcEchoerClient{cc: cc, serviceID: SRPCEchoerServiceID}
31
+ }
32
+
33
+ func NewSRPCEchoerClientWithServiceID(cc srpc.Client, serviceID string) SRPCEchoerClient {
34
+ if serviceID == "" {
35
+ serviceID = SRPCEchoerServiceID
36
+ }
37
+ return &srpcEchoerClient{cc: cc, serviceID: serviceID}
30
38
  }
31
39
 
32
40
  func (c *srpcEchoerClient) SRPCClient() srpc.Client { return c.cc }
33
41
 
34
42
  func (c *srpcEchoerClient) Echo(ctx context.Context, in *EchoMsg) (*EchoMsg, error) {
35
43
  out := new(EchoMsg)
36
- err := c.cc.Invoke(ctx, "echo.Echoer", "Echo", in, out)
44
+ err := c.cc.Invoke(ctx, c.serviceID, "Echo", in, out)
37
45
  if err != nil {
38
46
  return nil, err
39
47
  }
@@ -41,7 +49,7 @@ func (c *srpcEchoerClient) Echo(ctx context.Context, in *EchoMsg) (*EchoMsg, err
41
49
  }
42
50
 
43
51
  func (c *srpcEchoerClient) EchoServerStream(ctx context.Context, in *EchoMsg) (SRPCEchoer_EchoServerStreamClient, error) {
44
- stream, err := c.cc.NewStream(ctx, "echo.Echoer", "EchoServerStream", in)
52
+ stream, err := c.cc.NewStream(ctx, c.serviceID, "EchoServerStream", in)
45
53
  if err != nil {
46
54
  return nil, err
47
55
  }
@@ -75,7 +83,7 @@ func (x *srpcEchoer_EchoServerStreamClient) RecvTo(m *EchoMsg) error {
75
83
  }
76
84
 
77
85
  func (c *srpcEchoerClient) EchoClientStream(ctx context.Context) (SRPCEchoer_EchoClientStreamClient, error) {
78
- stream, err := c.cc.NewStream(ctx, "echo.Echoer", "EchoClientStream", nil)
86
+ stream, err := c.cc.NewStream(ctx, c.serviceID, "EchoClientStream", nil)
79
87
  if err != nil {
80
88
  return nil, err
81
89
  }
@@ -116,7 +124,7 @@ func (x *srpcEchoer_EchoClientStreamClient) CloseAndMsgRecv(m *EchoMsg) error {
116
124
  }
117
125
 
118
126
  func (c *srpcEchoerClient) EchoBidiStream(ctx context.Context) (SRPCEchoer_EchoBidiStreamClient, error) {
119
- stream, err := c.cc.NewStream(ctx, "echo.Echoer", "EchoBidiStream", nil)
127
+ stream, err := c.cc.NewStream(ctx, c.serviceID, "EchoBidiStream", nil)
120
128
  if err != nil {
121
129
  return nil, err
122
130
  }
@@ -152,7 +160,7 @@ func (x *srpcEchoer_EchoBidiStreamClient) RecvTo(m *EchoMsg) error {
152
160
  }
153
161
 
154
162
  func (c *srpcEchoerClient) RpcStream(ctx context.Context) (SRPCEchoer_RpcStreamClient, error) {
155
- stream, err := c.cc.NewStream(ctx, "echo.Echoer", "RpcStream", nil)
163
+ stream, err := c.cc.NewStream(ctx, c.serviceID, "RpcStream", nil)
156
164
  if err != nil {
157
165
  return nil, err
158
166
  }
@@ -238,6 +246,7 @@ func NewSRPCEchoerHandler(impl SRPCEchoerServer, serviceID string) srpc.Handler
238
246
  func SRPCRegisterEchoer(mux srpc.Mux, impl SRPCEchoerServer) error {
239
247
  return mux.Register(NewSRPCEchoerHandler(impl, ""))
240
248
  }
249
+
241
250
  func (d *SRPCEchoerHandler) GetServiceID() string { return d.serviceID }
242
251
 
243
252
  func (SRPCEchoerHandler) GetMethodIDs() []string {