starpc 0.0.1 → 0.1.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.
- package/LICENSE +19 -0
- package/Makefile +140 -0
- package/README.md +128 -26
- package/dist/echo/echo.d.ts +59 -0
- package/dist/echo/echo.js +85 -0
- package/dist/srpc/broadcast-channel.d.ts +16 -0
- package/dist/srpc/broadcast-channel.js +60 -0
- package/dist/srpc/client-rpc.d.ts +31 -0
- package/dist/srpc/client-rpc.js +176 -0
- package/dist/srpc/client.d.ts +12 -0
- package/dist/srpc/client.js +129 -0
- package/dist/srpc/conn.d.ts +14 -0
- package/dist/srpc/conn.js +38 -0
- package/dist/srpc/index.d.ts +3 -0
- package/dist/srpc/index.js +2 -0
- package/dist/srpc/packet.d.ts +9 -0
- package/dist/srpc/packet.js +89 -0
- package/dist/srpc/rpcproto.d.ts +194 -0
- package/dist/srpc/rpcproto.js +322 -0
- package/dist/srpc/stream.d.ts +5 -0
- package/dist/srpc/stream.js +1 -0
- package/dist/srpc/ts-proto-rpc.d.ts +7 -0
- package/dist/srpc/ts-proto-rpc.js +1 -0
- package/dist/srpc/websocket.d.ts +7 -0
- package/dist/srpc/websocket.js +18 -0
- package/e2e/e2e.go +1 -0
- package/e2e/e2e_test.go +158 -0
- package/echo/echo.go +1 -0
- package/echo/echo.pb.go +165 -0
- package/echo/echo.proto +19 -0
- package/echo/echo.ts +191 -0
- package/echo/echo_srpc.pb.go +333 -0
- package/echo/echo_vtproto.pb.go +271 -0
- package/echo/server.go +73 -0
- package/go.mod +50 -0
- package/go.sum +210 -0
- package/integration/integration.bash +25 -0
- package/integration/integration.go +30 -0
- package/integration/integration.ts +54 -0
- package/integration/tsconfig.json +11 -0
- package/package.json +77 -9
- package/patches/@libp2p+mplex+1.2.1.patch +22 -0
- package/srpc/broadcast-channel.ts +72 -0
- package/srpc/client-rpc.go +163 -0
- package/srpc/client-rpc.ts +197 -0
- package/srpc/client.go +96 -0
- package/srpc/client.ts +182 -0
- package/srpc/conn.go +7 -0
- package/srpc/conn.ts +49 -0
- package/srpc/errors.go +20 -0
- package/srpc/handler.go +13 -0
- package/srpc/index.ts +3 -0
- package/srpc/message.go +7 -0
- package/srpc/mux.go +76 -0
- package/srpc/packet-rw.go +102 -0
- package/srpc/packet.go +71 -0
- package/srpc/packet.ts +105 -0
- package/srpc/rpc-stream.go +76 -0
- package/srpc/rpcproto.pb.go +455 -0
- package/srpc/rpcproto.proto +46 -0
- package/srpc/rpcproto.ts +467 -0
- package/srpc/rpcproto_vtproto.pb.go +1094 -0
- package/srpc/server-http.go +66 -0
- package/srpc/server-pipe.go +26 -0
- package/srpc/server-rpc.go +160 -0
- package/srpc/server.go +29 -0
- package/srpc/stream-pipe.go +86 -0
- package/srpc/stream.go +24 -0
- package/srpc/stream.ts +11 -0
- package/srpc/ts-proto-rpc.ts +29 -0
- package/srpc/websocket.go +68 -0
- package/srpc/websocket.ts +22 -0
- package/srpc/writer.go +9 -0
package/srpc/packet.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { Source, Transform } from 'it-stream-types'
|
|
2
|
+
import { Packet } from './rpcproto'
|
|
3
|
+
import {
|
|
4
|
+
encode as lengthPrefixEncode,
|
|
5
|
+
decode as lengthPrefixDecode,
|
|
6
|
+
} from 'it-length-prefixed'
|
|
7
|
+
|
|
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
|
+
}
|
|
22
|
+
|
|
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
|
+
}
|
|
37
|
+
|
|
38
|
+
// uint32LEDecode removes the length prefix.
|
|
39
|
+
const uint32LEDecode = (data: Uint8Array) => {
|
|
40
|
+
if (data.length < 4) {
|
|
41
|
+
throw RangeError('Could not decode int32BE')
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const view = new DataView(data.buffer, data.byteOffset, data.byteLength)
|
|
45
|
+
return view.getUint32(0, true)
|
|
46
|
+
}
|
|
47
|
+
uint32LEDecode.bytes = 4
|
|
48
|
+
|
|
49
|
+
// uint32LEEncode adds the length prefix.
|
|
50
|
+
const uint32LEEncode = (value: number, target?: Uint8Array, offset?: number) => {
|
|
51
|
+
target = target ?? new Uint8Array(4)
|
|
52
|
+
const view = new DataView(target.buffer, target.byteOffset, target.byteLength)
|
|
53
|
+
view.setUint32(offset ?? 0, value, true)
|
|
54
|
+
return target
|
|
55
|
+
}
|
|
56
|
+
uint32LEEncode.bytes = 4
|
|
57
|
+
|
|
58
|
+
// prependLengthPrefixTransform adds a length prefix to a message source.
|
|
59
|
+
// little-endian uint32
|
|
60
|
+
export function prependLengthPrefixTransform(): Transform<Uint8Array> {
|
|
61
|
+
return lengthPrefixEncode({lengthEncoder: uint32LEEncode})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// parseLengthPrefixTransform parses the length prefix from a message source.
|
|
65
|
+
// little-endian uint32
|
|
66
|
+
export function parseLengthPrefixTransform(): Transform<Uint8Array> {
|
|
67
|
+
return lengthPrefixDecode({ lengthDecoder: uint32LEDecode })
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// encodeUint32Le encodes the number as a uint32 with little endian.
|
|
71
|
+
export function encodeUint32Le(value: number): Uint8Array {
|
|
72
|
+
// output is a 4 byte array
|
|
73
|
+
const output = new Uint8Array(4)
|
|
74
|
+
for (let index = 0; index < output.length; index++) {
|
|
75
|
+
const b = value & 0xff
|
|
76
|
+
output[index] = b
|
|
77
|
+
value = (value - b) / 256
|
|
78
|
+
}
|
|
79
|
+
return output
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// decodeUint32Le decodes a uint32 from a 4 byte Uint8Array.
|
|
83
|
+
// returns 0 if decoding failed.
|
|
84
|
+
// callers should check that len(data) == 4
|
|
85
|
+
export function decodeUint32Le(data: Uint8Array): number {
|
|
86
|
+
let value = 0
|
|
87
|
+
let nbytes = 4
|
|
88
|
+
if (data.length < nbytes) {
|
|
89
|
+
nbytes = data.length
|
|
90
|
+
}
|
|
91
|
+
for (let i = nbytes - 1; i >= 0; i--) {
|
|
92
|
+
value = value * 256 + data[i]
|
|
93
|
+
}
|
|
94
|
+
return value
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// prependPacketLen adds the message length prefix to a packet.
|
|
98
|
+
export function prependPacketLen(msgData: Uint8Array): Uint8Array {
|
|
99
|
+
const msgLen = msgData.length
|
|
100
|
+
const msgLenData = encodeUint32Le(msgLen)
|
|
101
|
+
const merged = new Uint8Array(msgLen + msgLenData.length)
|
|
102
|
+
merged.set(msgLenData)
|
|
103
|
+
merged.set(msgData, msgLenData.length)
|
|
104
|
+
return merged
|
|
105
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
package srpc
|
|
2
|
+
|
|
3
|
+
import (
|
|
4
|
+
"context"
|
|
5
|
+
"io"
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
// RPCStream implements the stream interface passed to implementations.
|
|
9
|
+
type RPCStream struct {
|
|
10
|
+
// ctx is the stream context
|
|
11
|
+
ctx context.Context
|
|
12
|
+
// writer is the stream writer
|
|
13
|
+
writer Writer
|
|
14
|
+
// dataCh is the incoming data channel.
|
|
15
|
+
dataCh chan []byte
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// NewRPCStream constructs a new Stream with a ClientRPC.
|
|
19
|
+
// dataCh should be closed when no more messages will arrive.
|
|
20
|
+
func NewRPCStream(ctx context.Context, writer Writer, dataCh chan []byte) *RPCStream {
|
|
21
|
+
return &RPCStream{
|
|
22
|
+
ctx: ctx,
|
|
23
|
+
writer: writer,
|
|
24
|
+
dataCh: dataCh,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Context is canceled when the Stream is no longer valid.
|
|
29
|
+
func (r *RPCStream) Context() context.Context {
|
|
30
|
+
return r.ctx
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// MsgSend sends the message to the remote.
|
|
34
|
+
func (r *RPCStream) MsgSend(msg Message) error {
|
|
35
|
+
select {
|
|
36
|
+
case <-r.ctx.Done():
|
|
37
|
+
return context.Canceled
|
|
38
|
+
default:
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
msgData, err := msg.MarshalVT()
|
|
42
|
+
if err != nil {
|
|
43
|
+
return err
|
|
44
|
+
}
|
|
45
|
+
outPkt := NewCallDataPacket(msgData, false, nil)
|
|
46
|
+
return r.writer.WritePacket(outPkt)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// MsgRecv receives an incoming message from the remote.
|
|
50
|
+
// Parses the message into the object at msg.
|
|
51
|
+
func (r *RPCStream) MsgRecv(msg Message) error {
|
|
52
|
+
select {
|
|
53
|
+
case <-r.Context().Done():
|
|
54
|
+
return context.Canceled
|
|
55
|
+
case data, ok := <-r.dataCh:
|
|
56
|
+
if !ok {
|
|
57
|
+
return io.EOF
|
|
58
|
+
}
|
|
59
|
+
return msg.UnmarshalVT(data)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// CloseSend signals to the remote that we will no longer send any messages.
|
|
64
|
+
func (r *RPCStream) CloseSend() error {
|
|
65
|
+
outPkt := NewCallDataPacket(nil, true, nil)
|
|
66
|
+
return r.writer.WritePacket(outPkt)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Close closes the stream.
|
|
70
|
+
func (r *RPCStream) Close() error {
|
|
71
|
+
_ = r.writer.Close()
|
|
72
|
+
return nil
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// _ is a type assertion
|
|
76
|
+
var _ Stream = ((*RPCStream)(nil))
|
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
// Code generated by protoc-gen-go. DO NOT EDIT.
|
|
2
|
+
// versions:
|
|
3
|
+
// protoc-gen-go v1.27.1-devel
|
|
4
|
+
// protoc v3.19.3
|
|
5
|
+
// source: github.com/aperturerobotics/starpc/srpc/rpcproto.proto
|
|
6
|
+
|
|
7
|
+
package srpc
|
|
8
|
+
|
|
9
|
+
import (
|
|
10
|
+
reflect "reflect"
|
|
11
|
+
sync "sync"
|
|
12
|
+
|
|
13
|
+
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
|
14
|
+
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
const (
|
|
18
|
+
// Verify that this generated code is sufficiently up-to-date.
|
|
19
|
+
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
|
20
|
+
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
|
21
|
+
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
// Packet is a message sent over a srpc packet connection.
|
|
25
|
+
type Packet struct {
|
|
26
|
+
state protoimpl.MessageState
|
|
27
|
+
sizeCache protoimpl.SizeCache
|
|
28
|
+
unknownFields protoimpl.UnknownFields
|
|
29
|
+
|
|
30
|
+
// Body is the packet body.
|
|
31
|
+
//
|
|
32
|
+
// Types that are assignable to Body:
|
|
33
|
+
// *Packet_CallStart
|
|
34
|
+
// *Packet_CallStartResp
|
|
35
|
+
// *Packet_CallData
|
|
36
|
+
Body isPacket_Body `protobuf_oneof:"body"`
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
func (x *Packet) Reset() {
|
|
40
|
+
*x = Packet{}
|
|
41
|
+
if protoimpl.UnsafeEnabled {
|
|
42
|
+
mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[0]
|
|
43
|
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
44
|
+
ms.StoreMessageInfo(mi)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
func (x *Packet) String() string {
|
|
49
|
+
return protoimpl.X.MessageStringOf(x)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
func (*Packet) ProtoMessage() {}
|
|
53
|
+
|
|
54
|
+
func (x *Packet) ProtoReflect() protoreflect.Message {
|
|
55
|
+
mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[0]
|
|
56
|
+
if protoimpl.UnsafeEnabled && x != nil {
|
|
57
|
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
58
|
+
if ms.LoadMessageInfo() == nil {
|
|
59
|
+
ms.StoreMessageInfo(mi)
|
|
60
|
+
}
|
|
61
|
+
return ms
|
|
62
|
+
}
|
|
63
|
+
return mi.MessageOf(x)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Deprecated: Use Packet.ProtoReflect.Descriptor instead.
|
|
67
|
+
func (*Packet) Descriptor() ([]byte, []int) {
|
|
68
|
+
return file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescGZIP(), []int{0}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
func (m *Packet) GetBody() isPacket_Body {
|
|
72
|
+
if m != nil {
|
|
73
|
+
return m.Body
|
|
74
|
+
}
|
|
75
|
+
return nil
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
func (x *Packet) GetCallStart() *CallStart {
|
|
79
|
+
if x, ok := x.GetBody().(*Packet_CallStart); ok {
|
|
80
|
+
return x.CallStart
|
|
81
|
+
}
|
|
82
|
+
return nil
|
|
83
|
+
}
|
|
84
|
+
|
|
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
|
+
func (x *Packet) GetCallData() *CallData {
|
|
93
|
+
if x, ok := x.GetBody().(*Packet_CallData); ok {
|
|
94
|
+
return x.CallData
|
|
95
|
+
}
|
|
96
|
+
return nil
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
type isPacket_Body interface {
|
|
100
|
+
isPacket_Body()
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
type Packet_CallStart struct {
|
|
104
|
+
// CallStart initiates a new call.
|
|
105
|
+
CallStart *CallStart `protobuf:"bytes,1,opt,name=call_start,json=callStart,proto3,oneof"`
|
|
106
|
+
}
|
|
107
|
+
|
|
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
|
+
type Packet_CallData struct {
|
|
114
|
+
// CallData is a message in a streaming RPC sequence.
|
|
115
|
+
CallData *CallData `protobuf:"bytes,3,opt,name=call_data,json=callData,proto3,oneof"`
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
func (*Packet_CallStart) isPacket_Body() {}
|
|
119
|
+
|
|
120
|
+
func (*Packet_CallStartResp) isPacket_Body() {}
|
|
121
|
+
|
|
122
|
+
func (*Packet_CallData) isPacket_Body() {}
|
|
123
|
+
|
|
124
|
+
// CallStart requests starting a new RPC call.
|
|
125
|
+
type CallStart struct {
|
|
126
|
+
state protoimpl.MessageState
|
|
127
|
+
sizeCache protoimpl.SizeCache
|
|
128
|
+
unknownFields protoimpl.UnknownFields
|
|
129
|
+
|
|
130
|
+
// RpcService is the service to contact.
|
|
131
|
+
// Must be set.
|
|
132
|
+
RpcService string `protobuf:"bytes,1,opt,name=rpc_service,json=rpcService,proto3" json:"rpc_service,omitempty"`
|
|
133
|
+
// RpcMethod is the RPC method to call.
|
|
134
|
+
// Must be set.
|
|
135
|
+
RpcMethod string `protobuf:"bytes,2,opt,name=rpc_method,json=rpcMethod,proto3" json:"rpc_method,omitempty"`
|
|
136
|
+
// Data contains the request or the first message in the stream.
|
|
137
|
+
// Optional if streaming.
|
|
138
|
+
Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
func (x *CallStart) Reset() {
|
|
142
|
+
*x = CallStart{}
|
|
143
|
+
if protoimpl.UnsafeEnabled {
|
|
144
|
+
mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[1]
|
|
145
|
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
146
|
+
ms.StoreMessageInfo(mi)
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
func (x *CallStart) String() string {
|
|
151
|
+
return protoimpl.X.MessageStringOf(x)
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
func (*CallStart) ProtoMessage() {}
|
|
155
|
+
|
|
156
|
+
func (x *CallStart) ProtoReflect() protoreflect.Message {
|
|
157
|
+
mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[1]
|
|
158
|
+
if protoimpl.UnsafeEnabled && x != nil {
|
|
159
|
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
160
|
+
if ms.LoadMessageInfo() == nil {
|
|
161
|
+
ms.StoreMessageInfo(mi)
|
|
162
|
+
}
|
|
163
|
+
return ms
|
|
164
|
+
}
|
|
165
|
+
return mi.MessageOf(x)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
// Deprecated: Use CallStart.ProtoReflect.Descriptor instead.
|
|
169
|
+
func (*CallStart) Descriptor() ([]byte, []int) {
|
|
170
|
+
return file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescGZIP(), []int{1}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
func (x *CallStart) GetRpcService() string {
|
|
174
|
+
if x != nil {
|
|
175
|
+
return x.RpcService
|
|
176
|
+
}
|
|
177
|
+
return ""
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
func (x *CallStart) GetRpcMethod() string {
|
|
181
|
+
if x != nil {
|
|
182
|
+
return x.RpcMethod
|
|
183
|
+
}
|
|
184
|
+
return ""
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
func (x *CallStart) GetData() []byte {
|
|
188
|
+
if x != nil {
|
|
189
|
+
return x.Data
|
|
190
|
+
}
|
|
191
|
+
return nil
|
|
192
|
+
}
|
|
193
|
+
|
|
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 {
|
|
238
|
+
if x != nil {
|
|
239
|
+
return x.Error
|
|
240
|
+
}
|
|
241
|
+
return ""
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// CallData contains a message in a streaming RPC sequence.
|
|
245
|
+
type CallData struct {
|
|
246
|
+
state protoimpl.MessageState
|
|
247
|
+
sizeCache protoimpl.SizeCache
|
|
248
|
+
unknownFields protoimpl.UnknownFields
|
|
249
|
+
|
|
250
|
+
// Data contains the packet in the sequence.
|
|
251
|
+
Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
|
|
252
|
+
// Complete indicates the RPC call is completed.
|
|
253
|
+
Complete bool `protobuf:"varint,2,opt,name=complete,proto3" json:"complete,omitempty"`
|
|
254
|
+
// Error contains any error that caused the RPC to fail.
|
|
255
|
+
// If set, implies complete=true.
|
|
256
|
+
Error string `protobuf:"bytes,3,opt,name=error,proto3" json:"error,omitempty"`
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
func (x *CallData) Reset() {
|
|
260
|
+
*x = CallData{}
|
|
261
|
+
if protoimpl.UnsafeEnabled {
|
|
262
|
+
mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[3]
|
|
263
|
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
264
|
+
ms.StoreMessageInfo(mi)
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
func (x *CallData) String() string {
|
|
269
|
+
return protoimpl.X.MessageStringOf(x)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
func (*CallData) ProtoMessage() {}
|
|
273
|
+
|
|
274
|
+
func (x *CallData) ProtoReflect() protoreflect.Message {
|
|
275
|
+
mi := &file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[3]
|
|
276
|
+
if protoimpl.UnsafeEnabled && x != nil {
|
|
277
|
+
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
|
278
|
+
if ms.LoadMessageInfo() == nil {
|
|
279
|
+
ms.StoreMessageInfo(mi)
|
|
280
|
+
}
|
|
281
|
+
return ms
|
|
282
|
+
}
|
|
283
|
+
return mi.MessageOf(x)
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// Deprecated: Use CallData.ProtoReflect.Descriptor instead.
|
|
287
|
+
func (*CallData) Descriptor() ([]byte, []int) {
|
|
288
|
+
return file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescGZIP(), []int{3}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
func (x *CallData) GetData() []byte {
|
|
292
|
+
if x != nil {
|
|
293
|
+
return x.Data
|
|
294
|
+
}
|
|
295
|
+
return nil
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
func (x *CallData) GetComplete() bool {
|
|
299
|
+
if x != nil {
|
|
300
|
+
return x.Complete
|
|
301
|
+
}
|
|
302
|
+
return false
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
func (x *CallData) GetError() string {
|
|
306
|
+
if x != nil {
|
|
307
|
+
return x.Error
|
|
308
|
+
}
|
|
309
|
+
return ""
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
var File_github_com_aperturerobotics_starpc_srpc_rpcproto_proto protoreflect.FileDescriptor
|
|
313
|
+
|
|
314
|
+
var file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDesc = []byte{
|
|
315
|
+
0x0a, 0x36, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x70, 0x65,
|
|
316
|
+
0x72, 0x74, 0x75, 0x72, 0x65, 0x72, 0x6f, 0x62, 0x6f, 0x74, 0x69, 0x63, 0x73, 0x2f, 0x73, 0x74,
|
|
317
|
+
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,
|
|
328
|
+
0x73, 0x72, 0x70, 0x63, 0x2e, 0x43, 0x61, 0x6c, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x48, 0x00, 0x52,
|
|
329
|
+
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,
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
var (
|
|
348
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescOnce sync.Once
|
|
349
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescData = file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDesc
|
|
350
|
+
)
|
|
351
|
+
|
|
352
|
+
func file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescGZIP() []byte {
|
|
353
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescOnce.Do(func() {
|
|
354
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescData = protoimpl.X.CompressGZIP(file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescData)
|
|
355
|
+
})
|
|
356
|
+
return file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDescData
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
var file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
|
|
360
|
+
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
|
|
365
|
+
}
|
|
366
|
+
var file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_depIdxs = []int32{
|
|
367
|
+
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
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
func init() { file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_init() }
|
|
378
|
+
func file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_init() {
|
|
379
|
+
if File_github_com_aperturerobotics_starpc_srpc_rpcproto_proto != nil {
|
|
380
|
+
return
|
|
381
|
+
}
|
|
382
|
+
if !protoimpl.UnsafeEnabled {
|
|
383
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
|
384
|
+
switch v := v.(*Packet); i {
|
|
385
|
+
case 0:
|
|
386
|
+
return &v.state
|
|
387
|
+
case 1:
|
|
388
|
+
return &v.sizeCache
|
|
389
|
+
case 2:
|
|
390
|
+
return &v.unknownFields
|
|
391
|
+
default:
|
|
392
|
+
return nil
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
|
396
|
+
switch v := v.(*CallStart); i {
|
|
397
|
+
case 0:
|
|
398
|
+
return &v.state
|
|
399
|
+
case 1:
|
|
400
|
+
return &v.sizeCache
|
|
401
|
+
case 2:
|
|
402
|
+
return &v.unknownFields
|
|
403
|
+
default:
|
|
404
|
+
return nil
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
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
|
+
switch v := v.(*CallData); i {
|
|
421
|
+
case 0:
|
|
422
|
+
return &v.state
|
|
423
|
+
case 1:
|
|
424
|
+
return &v.sizeCache
|
|
425
|
+
case 2:
|
|
426
|
+
return &v.unknownFields
|
|
427
|
+
default:
|
|
428
|
+
return nil
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes[0].OneofWrappers = []interface{}{
|
|
433
|
+
(*Packet_CallStart)(nil),
|
|
434
|
+
(*Packet_CallStartResp)(nil),
|
|
435
|
+
(*Packet_CallData)(nil),
|
|
436
|
+
}
|
|
437
|
+
type x struct{}
|
|
438
|
+
out := protoimpl.TypeBuilder{
|
|
439
|
+
File: protoimpl.DescBuilder{
|
|
440
|
+
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
|
441
|
+
RawDescriptor: file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDesc,
|
|
442
|
+
NumEnums: 0,
|
|
443
|
+
NumMessages: 4,
|
|
444
|
+
NumExtensions: 0,
|
|
445
|
+
NumServices: 0,
|
|
446
|
+
},
|
|
447
|
+
GoTypes: file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_goTypes,
|
|
448
|
+
DependencyIndexes: file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_depIdxs,
|
|
449
|
+
MessageInfos: file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_msgTypes,
|
|
450
|
+
}.Build()
|
|
451
|
+
File_github_com_aperturerobotics_starpc_srpc_rpcproto_proto = out.File
|
|
452
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_rawDesc = nil
|
|
453
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_goTypes = nil
|
|
454
|
+
file_github_com_aperturerobotics_starpc_srpc_rpcproto_proto_depIdxs = nil
|
|
455
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
syntax = "proto3";
|
|
2
|
+
package srpc;
|
|
3
|
+
|
|
4
|
+
// Packet is a message sent over a srpc packet connection.
|
|
5
|
+
message Packet {
|
|
6
|
+
// Body is the packet body.
|
|
7
|
+
oneof body {
|
|
8
|
+
// CallStart initiates a new call.
|
|
9
|
+
CallStart call_start = 1;
|
|
10
|
+
// CallStartResp is the response to CallStart.
|
|
11
|
+
CallStartResp call_start_resp = 2;
|
|
12
|
+
// CallData is a message in a streaming RPC sequence.
|
|
13
|
+
CallData call_data = 3;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// CallStart requests starting a new RPC call.
|
|
18
|
+
message CallStart {
|
|
19
|
+
// RpcService is the service to contact.
|
|
20
|
+
// Must be set.
|
|
21
|
+
string rpc_service = 1;
|
|
22
|
+
// RpcMethod is the RPC method to call.
|
|
23
|
+
// Must be set.
|
|
24
|
+
string rpc_method = 2;
|
|
25
|
+
// Data contains the request or the first message in the stream.
|
|
26
|
+
// Optional if streaming.
|
|
27
|
+
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;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// CallData contains a message in a streaming RPC sequence.
|
|
38
|
+
message CallData {
|
|
39
|
+
// Data contains the packet in the sequence.
|
|
40
|
+
bytes data = 1;
|
|
41
|
+
// Complete indicates the RPC call is completed.
|
|
42
|
+
bool complete = 2;
|
|
43
|
+
// Error contains any error that caused the RPC to fail.
|
|
44
|
+
// If set, implies complete=true.
|
|
45
|
+
string error = 3;
|
|
46
|
+
}
|