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.
Files changed (73) hide show
  1. package/Makefile +1 -0
  2. package/README.md +24 -5
  3. package/dist/echo/client-test.d.ts +2 -0
  4. package/dist/echo/client-test.js +35 -0
  5. package/dist/echo/echo.d.ts +124 -0
  6. package/dist/echo/echo.js +42 -0
  7. package/dist/echo/index.d.ts +3 -0
  8. package/dist/echo/index.js +3 -0
  9. package/dist/echo/server.d.ts +8 -0
  10. package/dist/echo/server.js +50 -0
  11. package/dist/echo/sever.d.ts +0 -0
  12. package/dist/echo/sever.js +1 -0
  13. package/dist/srpc/broadcast-channel.d.ts +3 -2
  14. package/dist/srpc/broadcast-channel.js +2 -2
  15. package/dist/srpc/client-rpc.d.ts +4 -28
  16. package/dist/srpc/client-rpc.js +9 -152
  17. package/dist/srpc/client.d.ts +2 -2
  18. package/dist/srpc/client.js +56 -84
  19. package/dist/srpc/common-rpc.d.ts +24 -0
  20. package/dist/srpc/common-rpc.js +140 -0
  21. package/dist/srpc/conn.d.ts +8 -3
  22. package/dist/srpc/conn.js +19 -3
  23. package/dist/srpc/definition.d.ts +15 -0
  24. package/dist/srpc/definition.js +1 -0
  25. package/dist/srpc/handler.d.ts +24 -0
  26. package/dist/srpc/handler.js +123 -0
  27. package/dist/srpc/index.d.ts +7 -3
  28. package/dist/srpc/index.js +6 -2
  29. package/dist/srpc/message.d.ts +11 -0
  30. package/dist/srpc/message.js +32 -0
  31. package/dist/srpc/mux.d.ts +11 -0
  32. package/dist/srpc/mux.js +36 -0
  33. package/dist/srpc/packet.d.ts +4 -4
  34. package/dist/srpc/packet.js +38 -27
  35. package/dist/srpc/rpcproto.d.ts +18 -43
  36. package/dist/srpc/rpcproto.js +37 -78
  37. package/dist/srpc/server-rpc.d.ts +11 -0
  38. package/dist/srpc/server-rpc.js +55 -0
  39. package/dist/srpc/server.d.ts +14 -0
  40. package/dist/srpc/server.js +31 -0
  41. package/dist/srpc/websocket.d.ts +3 -2
  42. package/dist/srpc/websocket.js +4 -4
  43. package/e2e/README.md +10 -0
  44. package/e2e/e2e.ts +27 -0
  45. package/echo/client-test.ts +41 -0
  46. package/echo/echo.ts +45 -0
  47. package/echo/index.ts +3 -0
  48. package/echo/server.ts +57 -0
  49. package/echo/sever.ts +0 -0
  50. package/integration/integration.bash +1 -1
  51. package/integration/integration.ts +10 -42
  52. package/package.json +18 -17
  53. package/srpc/broadcast-channel.ts +8 -3
  54. package/srpc/client-rpc.go +1 -9
  55. package/srpc/client-rpc.ts +11 -175
  56. package/srpc/client.ts +58 -99
  57. package/srpc/common-rpc.ts +171 -0
  58. package/srpc/conn.ts +33 -5
  59. package/srpc/definition.ts +30 -0
  60. package/srpc/handler.ts +174 -0
  61. package/srpc/index.ts +7 -3
  62. package/srpc/message.ts +60 -0
  63. package/srpc/mux.ts +56 -0
  64. package/srpc/packet.go +4 -11
  65. package/srpc/packet.ts +44 -30
  66. package/srpc/rpcproto.pb.go +54 -118
  67. package/srpc/rpcproto.proto +7 -12
  68. package/srpc/rpcproto.ts +38 -101
  69. package/srpc/rpcproto_vtproto.pb.go +58 -210
  70. package/srpc/server-rpc.go +5 -10
  71. package/srpc/server-rpc.ts +65 -0
  72. package/srpc/server.ts +56 -0
  73. package/srpc/websocket.ts +6 -4
@@ -0,0 +1,60 @@
1
+ import * as pbjs from 'protobufjs/minimal'
2
+ import type { Source } from 'it-stream-types'
3
+
4
+ // MessageDefinition represents a ts-proto message definition.
5
+ export interface MessageDefinition<T> {
6
+ // encode encodes the message and returns writer.
7
+ encode(message: T, writer?: pbjs.Writer): pbjs.Writer
8
+ // decode decodes the message from the reader
9
+ decode(input: pbjs.Reader | Uint8Array, length?: number): T
10
+ }
11
+
12
+ // DecodeMessageTransform decodes messages to objects.
13
+ type DecodeMessageTransform<T> = (
14
+ source: Source<Uint8Array | Uint8Array[]>
15
+ ) => AsyncIterable<T>
16
+
17
+ // buildDecodeMessageTransform builds a source of decoded messages.
18
+ export function buildDecodeMessageTransform<T>(
19
+ def: MessageDefinition<T>
20
+ ): DecodeMessageTransform<T> {
21
+ // decodeMessageSource unmarshals and async yields encoded Messages.
22
+ return async function* decodeMessageSource(
23
+ source: Source<Uint8Array | Uint8Array[]>
24
+ ): AsyncIterable<T> {
25
+ for await (const pkt of source) {
26
+ if (Array.isArray(pkt)) {
27
+ for (const p of pkt) {
28
+ yield* [def.decode(p)]
29
+ }
30
+ } else {
31
+ yield* [def.decode(pkt)]
32
+ }
33
+ }
34
+ }
35
+ }
36
+
37
+ // EncodeMessageTransform is a transformer that encodes messages.
38
+ type EncodeMessageTransform<T> = (
39
+ source: Source<T | T[]>
40
+ ) => AsyncIterable<Uint8Array>
41
+
42
+ // buildEncodeMessageTransform builds a source of decoded messages.
43
+ export function buildEncodeMessageTransform<T>(
44
+ def: MessageDefinition<T>
45
+ ): EncodeMessageTransform<T> {
46
+ // encodeMessageSource encodes messages to byte arrays.
47
+ return async function* encodeMessageSource(
48
+ source: Source<T | T[]>
49
+ ): AsyncIterable<Uint8Array> {
50
+ for await (const pkt of source) {
51
+ if (Array.isArray(pkt)) {
52
+ for (const p of pkt) {
53
+ yield* [def.encode(p).finish()]
54
+ }
55
+ } else {
56
+ yield* [def.encode(pkt).finish()]
57
+ }
58
+ }
59
+ }
60
+ }
package/srpc/mux.ts ADDED
@@ -0,0 +1,56 @@
1
+ import { InvokeFn, Handler } from './handler'
2
+
3
+ // Mux contains a set of <service, method> handlers.
4
+ export interface Mux {
5
+ // register registers a new RPC method handler.
6
+ register(handler: Handler): void
7
+ // lookupMethod looks up the method matching the service & method ID.
8
+ // returns null if not found.
9
+ lookupMethod(serviceID: string, methodID: string): Promise<InvokeFn | null>
10
+ }
11
+
12
+ // createMux builds a new Mux.
13
+ export function createMux(): Mux {
14
+ return new StaticMux()
15
+ }
16
+
17
+ // staticMuxMethods is a mapping from method id to handler.
18
+ type staticMuxMethods = { [methodID: string]: Handler }
19
+
20
+ // StaticMux contains a in-memory mapping between service ID and handlers.
21
+ // implements Mux
22
+ export class StaticMux implements Mux {
23
+ // services contains a mapping from service id to handlers.
24
+ private services: { [id: string]: staticMuxMethods } = {}
25
+
26
+ public register(handler: Handler): void {
27
+ const serviceID = handler?.getServiceID()
28
+ if (!serviceID) {
29
+ throw new Error('service id cannot be empty')
30
+ }
31
+ const serviceMethods = this.services[serviceID] || {}
32
+ const methodIDs = handler.getMethodIDs()
33
+ for (const methodID of methodIDs) {
34
+ serviceMethods[methodID] = handler
35
+ }
36
+ this.services[serviceID] = serviceMethods
37
+ }
38
+
39
+ public async lookupMethod(
40
+ serviceID: string,
41
+ methodID: string
42
+ ): Promise<InvokeFn | null> {
43
+ if (!serviceID) {
44
+ return null
45
+ }
46
+ const serviceMethods = this.services[serviceID]
47
+ if (!serviceMethods) {
48
+ return null
49
+ }
50
+ const handler = serviceMethods[methodID]
51
+ if (!handler) {
52
+ return null
53
+ }
54
+ return await handler.lookupMethod(serviceID, methodID)
55
+ }
56
+ }
package/srpc/packet.go CHANGED
@@ -10,8 +10,6 @@ func (p *Packet) Validate() error {
10
10
  return b.CallStart.Validate()
11
11
  case *Packet_CallData:
12
12
  return b.CallData.Validate()
13
- case *Packet_CallStartResp:
14
- return b.CallStartResp.Validate()
15
13
  default:
16
14
  return ErrUnrecognizedPacket
17
15
  }
@@ -49,9 +47,10 @@ func NewCallDataPacket(data []byte, complete bool, err error) *Packet {
49
47
  }
50
48
  return &Packet{Body: &Packet_CallData{
51
49
  CallData: &CallData{
52
- Data: data,
53
- Complete: err != nil || complete,
54
- Error: errStr,
50
+ Data: data,
51
+ DataIsZero: len(data) == 0 && !complete && err == nil,
52
+ Complete: err != nil || complete,
53
+ Error: errStr,
55
54
  },
56
55
  }}
57
56
  }
@@ -63,9 +62,3 @@ func (p *CallData) Validate() error {
63
62
  }
64
63
  return nil
65
64
  }
66
-
67
- // Validate performs cursory validation of the packet.
68
- func (p *CallStartResp) Validate() error {
69
- // nothing to check, empty packet is valid.
70
- return nil
71
- }
package/srpc/packet.ts CHANGED
@@ -1,39 +1,20 @@
1
- import type { Source, Transform } from 'it-stream-types'
2
- import { Packet } from './rpcproto'
1
+ import type { Transform } from 'it-stream-types'
3
2
  import {
4
3
  encode as lengthPrefixEncode,
5
4
  decode as lengthPrefixDecode,
6
5
  } from 'it-length-prefixed'
7
6
 
8
- // decodePacketSource unmarshals and async yields encoded Packets.
9
- export async function* decodePacketSource(
10
- source: Source<Uint8Array | Uint8Array[]>
11
- ): AsyncIterable<Packet> {
12
- for await (const pkt of source) {
13
- if (Array.isArray(pkt)) {
14
- for (const p of pkt) {
15
- yield* [Packet.decode(p)]
16
- }
17
- } else {
18
- yield* [Packet.decode(pkt)]
19
- }
20
- }
21
- }
7
+ import { Packet } from './rpcproto.js'
8
+ import {
9
+ buildDecodeMessageTransform,
10
+ buildEncodeMessageTransform,
11
+ } from './message.js'
22
12
 
23
- // encodePacketSource marshals and async yields packets.
24
- export async function* encodePacketSource(
25
- source: Source<Packet | Packet[]>
26
- ): AsyncIterable<Uint8Array> {
27
- for await (const pkt of source) {
28
- if (Array.isArray(pkt)) {
29
- for (const p of pkt) {
30
- yield* [Packet.encode(p).finish()]
31
- }
32
- } else {
33
- yield* [Packet.encode(pkt).finish()]
34
- }
35
- }
36
- }
13
+ // decodePacketSource decodes packets from a binary data stream.
14
+ export const decodePacketSource = buildDecodeMessageTransform<Packet>(Packet)
15
+
16
+ // encodePacketSource encodes packets from a packet object stream.
17
+ export const encodePacketSource = buildEncodeMessageTransform<Packet>(Packet)
37
18
 
38
19
  // uint32LEDecode removes the length prefix.
39
20
  const uint32LEDecode = (data: Uint8Array) => {
@@ -107,3 +88,36 @@ export function prependPacketLen(msgData: Uint8Array): Uint8Array {
107
88
  merged.set(msgData, msgLenData.length)
108
89
  return merged
109
90
  }
91
+
92
+ /*
93
+ // buildCallDataPacket builds a CallData packet.
94
+ function buildCallDataPacket(data: Uint8Array): Packet {
95
+ const callData: CallData = {
96
+ data: p,
97
+ complete: false,
98
+ error: '',
99
+ }
100
+ const pkt: Packet = {
101
+ body: {
102
+ $case: 'callData',
103
+ callData: callData,
104
+ }
105
+ }
106
+ return pkt
107
+ }
108
+
109
+ // wrapCallDataTransform is a transformer that wraps call data into a Packet.
110
+ export async function* wrapCallDataTransform(
111
+ source: Source<Uint8Array | Uint8Array>
112
+ ): AsyncIterable<Packet> {
113
+ for await (const pkt of source) {
114
+ if (Array.isArray(pkt)) {
115
+ for (const p of pkt) {
116
+ yield* [buildCallDataPacket(p)]
117
+ }
118
+ } else {
119
+ yield* [buildCallDataPacket(pkt)]
120
+ }
121
+ }
122
+ }
123
+ */
@@ -31,7 +31,6 @@ type Packet struct {
31
31
  //
32
32
  // Types that are assignable to Body:
33
33
  // *Packet_CallStart
34
- // *Packet_CallStartResp
35
34
  // *Packet_CallData
36
35
  Body isPacket_Body `protobuf_oneof:"body"`
37
36
  }
@@ -82,13 +81,6 @@ func (x *Packet) GetCallStart() *CallStart {
82
81
  return nil
83
82
  }
84
83
 
85
- func (x *Packet) GetCallStartResp() *CallStartResp {
86
- if x, ok := x.GetBody().(*Packet_CallStartResp); ok {
87
- return x.CallStartResp
88
- }
89
- return nil
90
- }
91
-
92
84
  func (x *Packet) GetCallData() *CallData {
93
85
  if x, ok := x.GetBody().(*Packet_CallData); ok {
94
86
  return x.CallData
@@ -105,20 +97,13 @@ type Packet_CallStart struct {
105
97
  CallStart *CallStart `protobuf:"bytes,1,opt,name=call_start,json=callStart,proto3,oneof"`
106
98
  }
107
99
 
108
- type Packet_CallStartResp struct {
109
- // CallStartResp is the response to CallStart.
110
- CallStartResp *CallStartResp `protobuf:"bytes,2,opt,name=call_start_resp,json=callStartResp,proto3,oneof"`
111
- }
112
-
113
100
  type Packet_CallData struct {
114
101
  // CallData is a message in a streaming RPC sequence.
115
- CallData *CallData `protobuf:"bytes,3,opt,name=call_data,json=callData,proto3,oneof"`
102
+ CallData *CallData `protobuf:"bytes,2,opt,name=call_data,json=callData,proto3,oneof"`
116
103
  }
117
104
 
118
105
  func (*Packet_CallStart) isPacket_Body() {}
119
106
 
120
- func (*Packet_CallStartResp) isPacket_Body() {}
121
-
122
107
  func (*Packet_CallData) isPacket_Body() {}
123
108
 
124
109
  // CallStart requests starting a new RPC call.
@@ -136,6 +121,8 @@ type CallStart struct {
136
121
  // Data contains the request or the first message in the stream.
137
122
  // Optional if streaming.
138
123
  Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
124
+ // DataIsZero indicates Data is set with an empty message.
125
+ DataIsZero bool `protobuf:"varint,4,opt,name=data_is_zero,json=dataIsZero,proto3" json:"data_is_zero,omitempty"`
139
126
  }
140
127
 
141
128
  func (x *CallStart) Reset() {
@@ -191,54 +178,11 @@ func (x *CallStart) GetData() []byte {
191
178
  return nil
192
179
  }
193
180
 
194
- // CallStartResp is the response to CallStart.
195
- type CallStartResp struct {
196
- state protoimpl.MessageState
197
- sizeCache protoimpl.SizeCache
198
- unknownFields protoimpl.UnknownFields
199
-
200
- // Error contains any error starting the RPC call.
201
- // Empty if successful.
202
- Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"`
203
- }
204
-
205
- func (x *CallStartResp) Reset() {
206
- *x = CallStartResp{}
207
- if protoimpl.UnsafeEnabled {
208
- mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[2]
209
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
210
- ms.StoreMessageInfo(mi)
211
- }
212
- }
213
-
214
- func (x *CallStartResp) String() string {
215
- return protoimpl.X.MessageStringOf(x)
216
- }
217
-
218
- func (*CallStartResp) ProtoMessage() {}
219
-
220
- func (x *CallStartResp) ProtoReflect() protoreflect.Message {
221
- mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[2]
222
- if protoimpl.UnsafeEnabled && x != nil {
223
- ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
224
- if ms.LoadMessageInfo() == nil {
225
- ms.StoreMessageInfo(mi)
226
- }
227
- return ms
228
- }
229
- return mi.MessageOf(x)
230
- }
231
-
232
- // Deprecated: Use CallStartResp.ProtoReflect.Descriptor instead.
233
- func (*CallStartResp) Descriptor() ([]byte, []int) {
234
- return file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescGZIP(), []int{2}
235
- }
236
-
237
- func (x *CallStartResp) GetError() string {
181
+ func (x *CallStart) GetDataIsZero() bool {
238
182
  if x != nil {
239
- return x.Error
183
+ return x.DataIsZero
240
184
  }
241
- return ""
185
+ return false
242
186
  }
243
187
 
244
188
  // CallData contains a message in a streaming RPC sequence.
@@ -249,17 +193,19 @@ type CallData struct {
249
193
 
250
194
  // Data contains the packet in the sequence.
251
195
  Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
196
+ // DataIsZero indicates Data is set with an empty message.
197
+ DataIsZero bool `protobuf:"varint,2,opt,name=data_is_zero,json=dataIsZero,proto3" json:"data_is_zero,omitempty"`
252
198
  // Complete indicates the RPC call is completed.
253
- Complete bool `protobuf:"varint,2,opt,name=complete,proto3" json:"complete,omitempty"`
199
+ Complete bool `protobuf:"varint,3,opt,name=complete,proto3" json:"complete,omitempty"`
254
200
  // Error contains any error that caused the RPC to fail.
255
201
  // If set, implies complete=true.
256
- Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
202
+ Error string `protobuf:"bytes,4,opt,name=error,proto3" json:"error,omitempty"`
257
203
  }
258
204
 
259
205
  func (x *CallData) Reset() {
260
206
  *x = CallData{}
261
207
  if protoimpl.UnsafeEnabled {
262
- mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[3]
208
+ mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[2]
263
209
  ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
264
210
  ms.StoreMessageInfo(mi)
265
211
  }
@@ -272,7 +218,7 @@ func (x *CallData) String() string {
272
218
  func (*CallData) ProtoMessage() {}
273
219
 
274
220
  func (x *CallData) ProtoReflect() protoreflect.Message {
275
- mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[3]
221
+ mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[2]
276
222
  if protoimpl.UnsafeEnabled && x != nil {
277
223
  ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
278
224
  if ms.LoadMessageInfo() == nil {
@@ -285,7 +231,7 @@ func (x *CallData) ProtoReflect() protoreflect.Message {
285
231
 
286
232
  // Deprecated: Use CallData.ProtoReflect.Descriptor instead.
287
233
  func (*CallData) Descriptor() ([]byte, []int) {
288
- return file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescGZIP(), []int{3}
234
+ return file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescGZIP(), []int{2}
289
235
  }
290
236
 
291
237
  func (x *CallData) GetData() []byte {
@@ -295,6 +241,13 @@ func (x *CallData) GetData() []byte {
295
241
  return nil
296
242
  }
297
243
 
244
+ func (x *CallData) GetDataIsZero() bool {
245
+ if x != nil {
246
+ return x.DataIsZero
247
+ }
248
+ return false
249
+ }
250
+
298
251
  func (x *CallData) GetComplete() bool {
299
252
  if x != nil {
300
253
  return x.Complete
@@ -315,33 +268,31 @@ var file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDesc = []byte
315
268
  0x0a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x70, 0x65,
316
269
  0x72, 0x74, 0x75, 0x72, 0x65, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x69, 0x63, 0x73, 0x2f, 0x73, 0x74,
317
270
  0x61, 0x72, 0x70, 0x63, 0x2f, 0x73, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x70, 0x72, 0x6f,
318
- 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x73, 0x72, 0x70, 0x63, 0x22, 0xb0,
319
- 0x01, 0x0a, 0x06, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x30, 0x0a, 0x0a, 0x63, 0x61, 0x6c,
320
- 0x6c, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e,
321
- 0x73, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x48, 0x00,
322
- 0x52, 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x3d, 0x0a, 0x0f, 0x63,
323
- 0x61, 0x6c, 0x6c, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x72, 0x65, 0x73, 0x70, 0x18, 0x02,
324
- 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x73, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c,
325
- 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x48, 0x00, 0x52, 0x0d, 0x63, 0x61, 0x6c,
326
- 0x6c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x2d, 0x0a, 0x09, 0x63, 0x61,
327
- 0x6c, 0x6c, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e,
271
+ 0x74, 0x6f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x73, 0x72, 0x70, 0x63, 0x22, 0x71,
272
+ 0x0a, 0x06, 0x50, 0x61, 0x63, 0x6b, 0x65, 0x74, 0x12, 0x30, 0x0a, 0x0a, 0x63, 0x61, 0x6c, 0x6c,
273
+ 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x73,
274
+ 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x48, 0x00, 0x52,
275
+ 0x09, 0x63, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x2d, 0x0a, 0x09, 0x63, 0x61,
276
+ 0x6c, 0x6c, 0x5f, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e,
328
277
  0x73, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52,
329
278
  0x08, 0x63, 0x61, 0x6c, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x0a, 0x04, 0x62, 0x6f, 0x64,
330
- 0x79, 0x22, 0x5f, 0x0a, 0x09, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x1f,
331
- 0x0a, 0x0b, 0x72, 0x70, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20,
332
- 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x70, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12,
333
- 0x1d, 0x0a, 0x0a, 0x72, 0x70, 0x63, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02, 0x20,
334
- 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x70, 0x63, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12, 0x12,
335
- 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61,
336
- 0x74, 0x61, 0x22, 0x25, 0x0a, 0x0d, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x52,
337
- 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x01, 0x20, 0x01,
338
- 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x50, 0x0a, 0x08, 0x43, 0x61, 0x6c,
339
- 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20,
340
- 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d,
341
- 0x70, 0x6c, 0x65, 0x74, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x63, 0x6f, 0x6d,
342
- 0x70, 0x6c, 0x65, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03,
343
- 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f,
344
- 0x74, 0x6f, 0x33,
279
+ 0x79, 0x22, 0x81, 0x01, 0x0a, 0x09, 0x43, 0x61, 0x6c, 0x6c, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12,
280
+ 0x1f, 0x0a, 0x0b, 0x72, 0x70, 0x63, 0x5f, 0x73, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x18, 0x01,
281
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x72, 0x70, 0x63, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
282
+ 0x12, 0x1d, 0x0a, 0x0a, 0x72, 0x70, 0x63, 0x5f, 0x6d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x18, 0x02,
283
+ 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x72, 0x70, 0x63, 0x4d, 0x65, 0x74, 0x68, 0x6f, 0x64, 0x12,
284
+ 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64,
285
+ 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0c, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x69, 0x73, 0x5f, 0x7a,
286
+ 0x65, 0x72, 0x6f, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x61, 0x74, 0x61, 0x49,
287
+ 0x73, 0x5a, 0x65, 0x72, 0x6f, 0x22, 0x72, 0x0a, 0x08, 0x43, 0x61, 0x6c, 0x6c, 0x44, 0x61, 0x74,
288
+ 0x61, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52,
289
+ 0x04, 0x64, 0x61, 0x74, 0x61, 0x12, 0x20, 0x0a, 0x0c, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x69, 0x73,
290
+ 0x5f, 0x7a, 0x65, 0x72, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x64, 0x61, 0x74,
291
+ 0x61, 0x49, 0x73, 0x5a, 0x65, 0x72, 0x6f, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c,
292
+ 0x65, 0x74, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x63, 0x6f, 0x6d, 0x70, 0x6c,
293
+ 0x65, 0x74, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x04, 0x20, 0x01,
294
+ 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
295
+ 0x33,
345
296
  }
346
297
 
347
298
  var (
@@ -356,22 +307,20 @@ func file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescGZIP() [
356
307
  return file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescData
357
308
  }
358
309
 
359
- var file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
310
+ var file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
360
311
  var file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_goTypes = []interface{}{
361
- (*Packet)(nil), // 0: srpc.Packet
362
- (*CallStart)(nil), // 1: srpc.CallStart
363
- (*CallStartResp)(nil), // 2: srpc.CallStartResp
364
- (*CallData)(nil), // 3: srpc.CallData
312
+ (*Packet)(nil), // 0: srpc.Packet
313
+ (*CallStart)(nil), // 1: srpc.CallStart
314
+ (*CallData)(nil), // 2: srpc.CallData
365
315
  }
366
316
  var file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_depIdxs = []int32{
367
317
  1, // 0: srpc.Packet.call_start:type_name -> srpc.CallStart
368
- 2, // 1: srpc.Packet.call_start_resp:type_name -> srpc.CallStartResp
369
- 3, // 2: srpc.Packet.call_data:type_name -> srpc.CallData
370
- 3, // [3:3] is the sub-list for method output_type
371
- 3, // [3:3] is the sub-list for method input_type
372
- 3, // [3:3] is the sub-list for extension type_name
373
- 3, // [3:3] is the sub-list for extension extendee
374
- 0, // [0:3] is the sub-list for field type_name
318
+ 2, // 1: srpc.Packet.call_data:type_name -> srpc.CallData
319
+ 2, // [2:2] is the sub-list for method output_type
320
+ 2, // [2:2] is the sub-list for method input_type
321
+ 2, // [2:2] is the sub-list for extension type_name
322
+ 2, // [2:2] is the sub-list for extension extendee
323
+ 0, // [0:2] is the sub-list for field type_name
375
324
  }
376
325
 
377
326
  func init() { file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_init() }
@@ -405,18 +354,6 @@ func file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_init() {
405
354
  }
406
355
  }
407
356
  file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
408
- switch v := v.(*CallStartResp); i {
409
- case 0:
410
- return &v.state
411
- case 1:
412
- return &v.sizeCache
413
- case 2:
414
- return &v.unknownFields
415
- default:
416
- return nil
417
- }
418
- }
419
- file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} {
420
357
  switch v := v.(*CallData); i {
421
358
  case 0:
422
359
  return &v.state
@@ -431,7 +368,6 @@ func file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_init() {
431
368
  }
432
369
  file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[0].OneofWrappers = []interface{}{
433
370
  (*Packet_CallStart)(nil),
434
- (*Packet_CallStartResp)(nil),
435
371
  (*Packet_CallData)(nil),
436
372
  }
437
373
  type x struct{}
@@ -440,7 +376,7 @@ func file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_init() {
440
376
  GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
441
377
  RawDescriptor: file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDesc,
442
378
  NumEnums: 0,
443
- NumMessages: 4,
379
+ NumMessages: 3,
444
380
  NumExtensions: 0,
445
381
  NumServices: 0,
446
382
  },
@@ -7,10 +7,8 @@ message Packet {
7
7
  oneof body {
8
8
  // CallStart initiates a new call.
9
9
  CallStart call_start = 1;
10
- // CallStartResp is the response to CallStart.
11
- CallStartResp call_start_resp = 2;
12
10
  // CallData is a message in a streaming RPC sequence.
13
- CallData call_data = 3;
11
+ CallData call_data = 2;
14
12
  }
15
13
  }
16
14
 
@@ -25,22 +23,19 @@ message CallStart {
25
23
  // Data contains the request or the first message in the stream.
26
24
  // Optional if streaming.
27
25
  bytes data = 3;
28
- }
29
-
30
- // CallStartResp is the response to CallStart.
31
- message CallStartResp {
32
- // Error contains any error starting the RPC call.
33
- // Empty if successful.
34
- string error = 1;
26
+ // DataIsZero indicates Data is set with an empty message.
27
+ bool data_is_zero = 4;
35
28
  }
36
29
 
37
30
  // CallData contains a message in a streaming RPC sequence.
38
31
  message CallData {
39
32
  // Data contains the packet in the sequence.
40
33
  bytes data = 1;
34
+ // DataIsZero indicates Data is set with an empty message.
35
+ bool data_is_zero = 2;
41
36
  // Complete indicates the RPC call is completed.
42
- bool complete = 2;
37
+ bool complete = 3;
43
38
  // Error contains any error that caused the RPC to fail.
44
39
  // If set, implies complete=true.
45
- string error = 3;
40
+ string error = 4;
46
41
  }