starpc 0.31.0 → 0.31.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/Makefile +1 -1
- package/cmd/protoc-gen-es-starpc/dev/protoc-gen-es-starpc +2 -0
- package/cmd/protoc-gen-es-starpc/plugin.ts +1 -2
- package/cmd/protoc-gen-es-starpc/protoc-gen-es-starpc +6 -2
- package/dist/cmd/protoc-gen-es-starpc/plugin.js +1 -2
- package/dist/e2e/mock/mock_pb.js +9 -9
- package/dist/e2e/mock/mock_srpc.pb.js +3 -1
- package/dist/echo/echo_pb.js +9 -9
- package/dist/echo/echo_srpc.pb.js +3 -1
- package/dist/echo/server.js +2 -0
- package/dist/rpcstream/rpcstream.js +8 -0
- package/dist/rpcstream/rpcstream_pb.js +44 -44
- package/dist/srpc/broadcast-channel.js +10 -0
- package/dist/srpc/channel.js +28 -0
- package/dist/srpc/client.js +2 -0
- package/dist/srpc/common-rpc.js +20 -8
- package/dist/srpc/conn.js +4 -0
- package/dist/srpc/handler.js +4 -0
- package/dist/srpc/message-port.js +8 -0
- package/dist/srpc/mux.js +5 -7
- package/dist/srpc/rpcproto_pb.js +92 -92
- package/dist/srpc/server-rpc.js +2 -0
- package/dist/srpc/server.js +2 -0
- package/dist/srpc/value-ctr.js +5 -0
- package/dist/srpc/watchdog.js +4 -2
- package/dist/srpc/websocket.js +2 -0
- package/e2e/mock/mock.pb.go +1 -1
- package/e2e/mock/mock_srpc.pb.ts +1 -1
- package/echo/echo.pb.go +1 -1
- package/echo/echo_srpc.pb.ts +1 -1
- package/go.mod +1 -1
- package/go.sum +2 -2
- package/package.json +3 -2
- package/srpc/rpcproto.pb.go +18 -18
- package/dist/package.json +0 -100
package/Makefile
CHANGED
|
@@ -85,7 +85,7 @@ genproto: vendor node_modules $(GOIMPORTS) $(PROTOWRAP) $(PROTOC_GEN_GO) $(PROTO
|
|
|
85
85
|
$(PROTOWRAP) \
|
|
86
86
|
-I $${OUT} \
|
|
87
87
|
--plugin=./node_modules/.bin/protoc-gen-es \
|
|
88
|
-
--plugin=./cmd/protoc-gen-es-starpc/protoc-gen-es-starpc \
|
|
88
|
+
--plugin=./cmd/protoc-gen-es-starpc/dev/protoc-gen-es-starpc \
|
|
89
89
|
--go-lite_out=$${OUT} \
|
|
90
90
|
--go-lite_opt=features=marshal+unmarshal+size+equal+json+clone \
|
|
91
91
|
--go-starpc_out=$${OUT} \
|
|
@@ -15,10 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
import { createEcmaScriptPlugin } from '@bufbuild/protoplugin'
|
|
17
17
|
import { generateTs } from './typescript.js'
|
|
18
|
-
import { version } from '../../package.json'
|
|
19
18
|
|
|
20
19
|
export const protocGenEsStarpc = createEcmaScriptPlugin({
|
|
21
20
|
name: 'protoc-gen-es-starpc',
|
|
22
|
-
version: `
|
|
21
|
+
version: `none`,
|
|
23
22
|
generateTs,
|
|
24
23
|
})
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
-
#!/usr/bin/env
|
|
2
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { runNodeJs } from "@bufbuild/protoplugin";
|
|
4
|
+
import { protocGenEsStarpc } from "../../dist/cmd/protoc-gen-es-starpc/plugin.js";
|
|
5
|
+
|
|
6
|
+
runNodeJs(protocGenEsStarpc)
|
|
@@ -14,9 +14,8 @@
|
|
|
14
14
|
// limitations under the License.
|
|
15
15
|
import { createEcmaScriptPlugin } from '@bufbuild/protoplugin';
|
|
16
16
|
import { generateTs } from './typescript.js';
|
|
17
|
-
import { version } from '../../package.json';
|
|
18
17
|
export const protocGenEsStarpc = createEcmaScriptPlugin({
|
|
19
18
|
name: 'protoc-gen-es-starpc',
|
|
20
|
-
version: `
|
|
19
|
+
version: `none`,
|
|
21
20
|
generateTs,
|
|
22
21
|
});
|
package/dist/e2e/mock/mock_pb.js
CHANGED
|
@@ -8,14 +8,19 @@ import { Message, proto3 } from '@bufbuild/protobuf';
|
|
|
8
8
|
* @generated from message e2e.mock.MockMsg
|
|
9
9
|
*/
|
|
10
10
|
export class MockMsg extends Message {
|
|
11
|
+
/**
|
|
12
|
+
* @generated from field: string body = 1;
|
|
13
|
+
*/
|
|
14
|
+
body = '';
|
|
11
15
|
constructor(data) {
|
|
12
16
|
super();
|
|
13
|
-
/**
|
|
14
|
-
* @generated from field: string body = 1;
|
|
15
|
-
*/
|
|
16
|
-
this.body = '';
|
|
17
17
|
proto3.util.initPartial(data, this);
|
|
18
18
|
}
|
|
19
|
+
static runtime = proto3;
|
|
20
|
+
static typeName = 'e2e.mock.MockMsg';
|
|
21
|
+
static fields = proto3.util.newFieldList(() => [
|
|
22
|
+
{ no: 1, name: 'body', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
23
|
+
]);
|
|
19
24
|
static fromBinary(bytes, options) {
|
|
20
25
|
return new MockMsg().fromBinary(bytes, options);
|
|
21
26
|
}
|
|
@@ -29,8 +34,3 @@ export class MockMsg extends Message {
|
|
|
29
34
|
return proto3.util.equals(MockMsg, a, b);
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
|
-
MockMsg.runtime = proto3;
|
|
33
|
-
MockMsg.typeName = 'e2e.mock.MockMsg';
|
|
34
|
-
MockMsg.fields = proto3.util.newFieldList(() => [
|
|
35
|
-
{ no: 1, name: 'body', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
36
|
-
]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-starpc
|
|
1
|
+
// @generated by protoc-gen-es-starpc none with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/e2e/mock/mock.proto (package e2e.mock, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
import { MockMsg } from './mock_pb.js';
|
|
@@ -26,6 +26,8 @@ export const MockDefinition = {
|
|
|
26
26
|
};
|
|
27
27
|
export const MockServiceName = MockDefinition.typeName;
|
|
28
28
|
export class MockClient {
|
|
29
|
+
rpc;
|
|
30
|
+
service;
|
|
29
31
|
constructor(rpc, opts) {
|
|
30
32
|
this.service = opts?.service || MockServiceName;
|
|
31
33
|
this.rpc = rpc;
|
package/dist/echo/echo_pb.js
CHANGED
|
@@ -8,14 +8,19 @@ import { Message, proto3 } from '@bufbuild/protobuf';
|
|
|
8
8
|
* @generated from message echo.EchoMsg
|
|
9
9
|
*/
|
|
10
10
|
export class EchoMsg extends Message {
|
|
11
|
+
/**
|
|
12
|
+
* @generated from field: string body = 1;
|
|
13
|
+
*/
|
|
14
|
+
body = '';
|
|
11
15
|
constructor(data) {
|
|
12
16
|
super();
|
|
13
|
-
/**
|
|
14
|
-
* @generated from field: string body = 1;
|
|
15
|
-
*/
|
|
16
|
-
this.body = '';
|
|
17
17
|
proto3.util.initPartial(data, this);
|
|
18
18
|
}
|
|
19
|
+
static runtime = proto3;
|
|
20
|
+
static typeName = 'echo.EchoMsg';
|
|
21
|
+
static fields = proto3.util.newFieldList(() => [
|
|
22
|
+
{ no: 1, name: 'body', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
23
|
+
]);
|
|
19
24
|
static fromBinary(bytes, options) {
|
|
20
25
|
return new EchoMsg().fromBinary(bytes, options);
|
|
21
26
|
}
|
|
@@ -29,8 +34,3 @@ export class EchoMsg extends Message {
|
|
|
29
34
|
return proto3.util.equals(EchoMsg, a, b);
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
|
-
EchoMsg.runtime = proto3;
|
|
33
|
-
EchoMsg.typeName = 'echo.EchoMsg';
|
|
34
|
-
EchoMsg.fields = proto3.util.newFieldList(() => [
|
|
35
|
-
{ no: 1, name: 'body', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
36
|
-
]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-starpc
|
|
1
|
+
// @generated by protoc-gen-es-starpc none with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/echo/echo.proto (package echo, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
import { EchoMsg } from './echo_pb.js';
|
|
@@ -72,6 +72,8 @@ export const EchoerDefinition = {
|
|
|
72
72
|
};
|
|
73
73
|
export const EchoerServiceName = EchoerDefinition.typeName;
|
|
74
74
|
export class EchoerClient {
|
|
75
|
+
rpc;
|
|
76
|
+
service;
|
|
75
77
|
constructor(rpc, opts) {
|
|
76
78
|
this.service = opts?.service || EchoerServiceName;
|
|
77
79
|
this.rpc = rpc;
|
package/dist/echo/server.js
CHANGED
|
@@ -3,6 +3,8 @@ import { messagePushable, writeToPushable } from '../srpc/pushable.js';
|
|
|
3
3
|
import { handleRpcStream } from '../rpcstream/rpcstream.js';
|
|
4
4
|
// EchoServer implements the Echoer server.
|
|
5
5
|
export class EchoerServer {
|
|
6
|
+
// proxyServer is the server used for RpcStream requests.
|
|
7
|
+
proxyServer;
|
|
6
8
|
constructor(proxyServer) {
|
|
7
9
|
this.proxyServer = proxyServer;
|
|
8
10
|
}
|
|
@@ -99,6 +99,14 @@ export async function* handleRpcStream(packetRx, getter) {
|
|
|
99
99
|
// RpcStream implements the PacketStream on top of a RPC call.
|
|
100
100
|
// Note: expects the stream to already have been negotiated.
|
|
101
101
|
export class RpcStream {
|
|
102
|
+
// source is the source for incoming Uint8Array packets.
|
|
103
|
+
source;
|
|
104
|
+
// sink is the sink for outgoing Uint8Array packets.
|
|
105
|
+
sink;
|
|
106
|
+
// _packetRx receives packets from the remote.
|
|
107
|
+
_packetRx;
|
|
108
|
+
// _packetTx writes packets to the remote.
|
|
109
|
+
_packetTx;
|
|
102
110
|
// packetTx writes packets to the remote.
|
|
103
111
|
// packetRx receives packets from the remote.
|
|
104
112
|
constructor(packetTx, packetRx) {
|
|
@@ -8,14 +8,27 @@ import { Message, proto3 } from '@bufbuild/protobuf';
|
|
|
8
8
|
* @generated from message rpcstream.RpcStreamPacket
|
|
9
9
|
*/
|
|
10
10
|
export class RpcStreamPacket extends Message {
|
|
11
|
+
/**
|
|
12
|
+
* @generated from oneof rpcstream.RpcStreamPacket.body
|
|
13
|
+
*/
|
|
14
|
+
body = { case: undefined };
|
|
11
15
|
constructor(data) {
|
|
12
16
|
super();
|
|
13
|
-
/**
|
|
14
|
-
* @generated from oneof rpcstream.RpcStreamPacket.body
|
|
15
|
-
*/
|
|
16
|
-
this.body = { case: undefined };
|
|
17
17
|
proto3.util.initPartial(data, this);
|
|
18
18
|
}
|
|
19
|
+
static runtime = proto3;
|
|
20
|
+
static typeName = 'rpcstream.RpcStreamPacket';
|
|
21
|
+
static fields = proto3.util.newFieldList(() => [
|
|
22
|
+
{ no: 1, name: 'init', kind: 'message', T: RpcStreamInit, oneof: 'body' },
|
|
23
|
+
{ no: 2, name: 'ack', kind: 'message', T: RpcAck, oneof: 'body' },
|
|
24
|
+
{
|
|
25
|
+
no: 3,
|
|
26
|
+
name: 'data',
|
|
27
|
+
kind: 'scalar',
|
|
28
|
+
T: 12 /* ScalarType.BYTES */,
|
|
29
|
+
oneof: 'body',
|
|
30
|
+
},
|
|
31
|
+
]);
|
|
19
32
|
static fromBinary(bytes, options) {
|
|
20
33
|
return new RpcStreamPacket().fromBinary(bytes, options);
|
|
21
34
|
}
|
|
@@ -29,35 +42,32 @@ export class RpcStreamPacket extends Message {
|
|
|
29
42
|
return proto3.util.equals(RpcStreamPacket, a, b);
|
|
30
43
|
}
|
|
31
44
|
}
|
|
32
|
-
RpcStreamPacket.runtime = proto3;
|
|
33
|
-
RpcStreamPacket.typeName = 'rpcstream.RpcStreamPacket';
|
|
34
|
-
RpcStreamPacket.fields = proto3.util.newFieldList(() => [
|
|
35
|
-
{ no: 1, name: 'init', kind: 'message', T: RpcStreamInit, oneof: 'body' },
|
|
36
|
-
{ no: 2, name: 'ack', kind: 'message', T: RpcAck, oneof: 'body' },
|
|
37
|
-
{
|
|
38
|
-
no: 3,
|
|
39
|
-
name: 'data',
|
|
40
|
-
kind: 'scalar',
|
|
41
|
-
T: 12 /* ScalarType.BYTES */,
|
|
42
|
-
oneof: 'body',
|
|
43
|
-
},
|
|
44
|
-
]);
|
|
45
45
|
/**
|
|
46
46
|
* RpcStreamInit is the first message in a RPC stream.
|
|
47
47
|
*
|
|
48
48
|
* @generated from message rpcstream.RpcStreamInit
|
|
49
49
|
*/
|
|
50
50
|
export class RpcStreamInit extends Message {
|
|
51
|
+
/**
|
|
52
|
+
* ComponentId is the identifier of the component making the request.
|
|
53
|
+
*
|
|
54
|
+
* @generated from field: string component_id = 1;
|
|
55
|
+
*/
|
|
56
|
+
componentId = '';
|
|
51
57
|
constructor(data) {
|
|
52
58
|
super();
|
|
53
|
-
/**
|
|
54
|
-
* ComponentId is the identifier of the component making the request.
|
|
55
|
-
*
|
|
56
|
-
* @generated from field: string component_id = 1;
|
|
57
|
-
*/
|
|
58
|
-
this.componentId = '';
|
|
59
59
|
proto3.util.initPartial(data, this);
|
|
60
60
|
}
|
|
61
|
+
static runtime = proto3;
|
|
62
|
+
static typeName = 'rpcstream.RpcStreamInit';
|
|
63
|
+
static fields = proto3.util.newFieldList(() => [
|
|
64
|
+
{
|
|
65
|
+
no: 1,
|
|
66
|
+
name: 'component_id',
|
|
67
|
+
kind: 'scalar',
|
|
68
|
+
T: 9 /* ScalarType.STRING */,
|
|
69
|
+
},
|
|
70
|
+
]);
|
|
61
71
|
static fromBinary(bytes, options) {
|
|
62
72
|
return new RpcStreamInit().fromBinary(bytes, options);
|
|
63
73
|
}
|
|
@@ -71,32 +81,27 @@ export class RpcStreamInit extends Message {
|
|
|
71
81
|
return proto3.util.equals(RpcStreamInit, a, b);
|
|
72
82
|
}
|
|
73
83
|
}
|
|
74
|
-
RpcStreamInit.runtime = proto3;
|
|
75
|
-
RpcStreamInit.typeName = 'rpcstream.RpcStreamInit';
|
|
76
|
-
RpcStreamInit.fields = proto3.util.newFieldList(() => [
|
|
77
|
-
{
|
|
78
|
-
no: 1,
|
|
79
|
-
name: 'component_id',
|
|
80
|
-
kind: 'scalar',
|
|
81
|
-
T: 9 /* ScalarType.STRING */,
|
|
82
|
-
},
|
|
83
|
-
]);
|
|
84
84
|
/**
|
|
85
85
|
* RpcAck is the ack message in a RPC stream.
|
|
86
86
|
*
|
|
87
87
|
* @generated from message rpcstream.RpcAck
|
|
88
88
|
*/
|
|
89
89
|
export class RpcAck extends Message {
|
|
90
|
+
/**
|
|
91
|
+
* Error indicates there was some error setting up the stream.
|
|
92
|
+
*
|
|
93
|
+
* @generated from field: string error = 1;
|
|
94
|
+
*/
|
|
95
|
+
error = '';
|
|
90
96
|
constructor(data) {
|
|
91
97
|
super();
|
|
92
|
-
/**
|
|
93
|
-
* Error indicates there was some error setting up the stream.
|
|
94
|
-
*
|
|
95
|
-
* @generated from field: string error = 1;
|
|
96
|
-
*/
|
|
97
|
-
this.error = '';
|
|
98
98
|
proto3.util.initPartial(data, this);
|
|
99
99
|
}
|
|
100
|
+
static runtime = proto3;
|
|
101
|
+
static typeName = 'rpcstream.RpcAck';
|
|
102
|
+
static fields = proto3.util.newFieldList(() => [
|
|
103
|
+
{ no: 1, name: 'error', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
104
|
+
]);
|
|
100
105
|
static fromBinary(bytes, options) {
|
|
101
106
|
return new RpcAck().fromBinary(bytes, options);
|
|
102
107
|
}
|
|
@@ -110,8 +115,3 @@ export class RpcAck extends Message {
|
|
|
110
115
|
return proto3.util.equals(RpcAck, a, b);
|
|
111
116
|
}
|
|
112
117
|
}
|
|
113
|
-
RpcAck.runtime = proto3;
|
|
114
|
-
RpcAck.typeName = 'rpcstream.RpcAck';
|
|
115
|
-
RpcAck.fields = proto3.util.newFieldList(() => [
|
|
116
|
-
{ no: 1, name: 'error', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
117
|
-
]);
|
|
@@ -8,6 +8,14 @@ import { pipe } from 'it-pipe';
|
|
|
8
8
|
// Note: there is no way to know when a BroadcastChannel is closed!
|
|
9
9
|
// You will need an additional keep-alive on top of BroadcastChannelDuplex.
|
|
10
10
|
export class BroadcastChannelDuplex {
|
|
11
|
+
// read is the read channel
|
|
12
|
+
read;
|
|
13
|
+
// write is the write channel
|
|
14
|
+
write;
|
|
15
|
+
// sink is the sink for incoming messages.
|
|
16
|
+
sink;
|
|
17
|
+
// source is the source for outgoing messages.
|
|
18
|
+
source;
|
|
11
19
|
constructor(read, write) {
|
|
12
20
|
this.read = read;
|
|
13
21
|
this.write = write;
|
|
@@ -73,6 +81,8 @@ export function newBroadcastChannelDuplex(readName, writeName) {
|
|
|
73
81
|
// expects Uint8Array objects over the BroadcastChannel.
|
|
74
82
|
// uses Yamux to mux streams over the port.
|
|
75
83
|
export class BroadcastChannelConn extends StreamConn {
|
|
84
|
+
// duplex is the broadcast channel duplex.
|
|
85
|
+
duplex;
|
|
76
86
|
constructor(duplex, server, connParams) {
|
|
77
87
|
super(server, {
|
|
78
88
|
...connParams,
|
package/dist/srpc/channel.js
CHANGED
|
@@ -9,6 +9,34 @@ import { ERR_STREAM_IDLE } from './errors.js';
|
|
|
9
9
|
// Enable keepAliveMs and idleTimeoutMs to mitigate this issue with keep-alive messages.
|
|
10
10
|
// NOTE: Browsers will throttle setTimeout in background tabs.
|
|
11
11
|
export class ChannelStream {
|
|
12
|
+
// channel is the read/write channel.
|
|
13
|
+
channel;
|
|
14
|
+
// sink is the sink for incoming messages.
|
|
15
|
+
sink;
|
|
16
|
+
// source is the source for outgoing messages.
|
|
17
|
+
source;
|
|
18
|
+
// _source emits incoming data to the source.
|
|
19
|
+
_source;
|
|
20
|
+
// localId is the local identifier
|
|
21
|
+
localId;
|
|
22
|
+
// localOpen indicates the local side has opened the stream.
|
|
23
|
+
localOpen;
|
|
24
|
+
// remoteOpen indicates the remote side has opened the stream.
|
|
25
|
+
remoteOpen;
|
|
26
|
+
// waitRemoteOpen indicates the remote side has opened the stream.
|
|
27
|
+
waitRemoteOpen;
|
|
28
|
+
// _remoteOpen fulfills the waitRemoteOpen promise.
|
|
29
|
+
_remoteOpen;
|
|
30
|
+
// remoteAck indicates the remote side has acked the stream.
|
|
31
|
+
remoteAck;
|
|
32
|
+
// waitRemoteAck indicates the remote side has opened the stream.
|
|
33
|
+
waitRemoteAck;
|
|
34
|
+
// _remoteAck fulfills the waitRemoteAck promise.
|
|
35
|
+
_remoteAck;
|
|
36
|
+
// keepAliveWatchdog is the transmission timeout watchdog.
|
|
37
|
+
keepAlive;
|
|
38
|
+
// idleWatchdog is the receive timeout watchdog.
|
|
39
|
+
idleWatchdog;
|
|
12
40
|
// isAcked checks if the stream is acknowledged by the remote.
|
|
13
41
|
get isAcked() {
|
|
14
42
|
return this.remoteAck ?? false;
|
package/dist/srpc/client.js
CHANGED
|
@@ -7,6 +7,8 @@ import { decodePacketSource, encodePacketSource } from './packet.js';
|
|
|
7
7
|
import { OpenStreamCtr } from './open-stream-ctr.js';
|
|
8
8
|
// Client implements the ts-proto Rpc interface with the drpcproto protocol.
|
|
9
9
|
export class Client {
|
|
10
|
+
// openStreamCtr contains the OpenStreamFunc.
|
|
11
|
+
openStreamCtr;
|
|
10
12
|
constructor(openStreamFn) {
|
|
11
13
|
this.openStreamCtr = new OpenStreamCtr(openStreamFn || undefined);
|
|
12
14
|
}
|
package/dist/srpc/common-rpc.js
CHANGED
|
@@ -3,15 +3,27 @@ import { Packet } from './rpcproto_pb.js';
|
|
|
3
3
|
import { ERR_RPC_ABORT } from './errors.js';
|
|
4
4
|
// CommonRPC is common logic between server and client RPCs.
|
|
5
5
|
export class CommonRPC {
|
|
6
|
+
// sink is the data sink for incoming messages.
|
|
7
|
+
sink;
|
|
8
|
+
// source is the packet source for outgoing Packets.
|
|
9
|
+
source;
|
|
10
|
+
// rpcDataSource is the source for rpc packets.
|
|
11
|
+
rpcDataSource;
|
|
12
|
+
// _source is used to write to the source.
|
|
13
|
+
_source = pushable({
|
|
14
|
+
objectMode: true,
|
|
15
|
+
});
|
|
16
|
+
// _rpcDataSource is used to write to the rpc message source.
|
|
17
|
+
_rpcDataSource = pushable({
|
|
18
|
+
objectMode: true,
|
|
19
|
+
});
|
|
20
|
+
// service is the rpc service
|
|
21
|
+
service;
|
|
22
|
+
// method is the rpc method
|
|
23
|
+
method;
|
|
24
|
+
// closed indicates this rpc has been closed already.
|
|
25
|
+
closed;
|
|
6
26
|
constructor() {
|
|
7
|
-
// _source is used to write to the source.
|
|
8
|
-
this._source = pushable({
|
|
9
|
-
objectMode: true,
|
|
10
|
-
});
|
|
11
|
-
// _rpcDataSource is used to write to the rpc message source.
|
|
12
|
-
this._rpcDataSource = pushable({
|
|
13
|
-
objectMode: true,
|
|
14
|
-
});
|
|
15
27
|
this.sink = this._createSink();
|
|
16
28
|
this.source = this._source;
|
|
17
29
|
this.rpcDataSource = this._rpcDataSource;
|
package/dist/srpc/conn.js
CHANGED
|
@@ -11,6 +11,10 @@ import { Client } from './client.js';
|
|
|
11
11
|
// Implements the server by handling incoming streams.
|
|
12
12
|
// If the server is unset, rejects any incoming streams.
|
|
13
13
|
export class StreamConn {
|
|
14
|
+
// muxer is the stream muxer.
|
|
15
|
+
_muxer;
|
|
16
|
+
// server is the server side, if set.
|
|
17
|
+
_server;
|
|
14
18
|
constructor(server, connParams) {
|
|
15
19
|
if (server) {
|
|
16
20
|
this._server = server;
|
package/dist/srpc/handler.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { createInvokeFn } from './invoker.js';
|
|
2
2
|
// StaticHandler is a handler with a definition and implementation.
|
|
3
3
|
export class StaticHandler {
|
|
4
|
+
// service is the service id
|
|
5
|
+
service;
|
|
6
|
+
// methods is the map of method to invoke fn
|
|
7
|
+
methods;
|
|
4
8
|
constructor(serviceID, methods) {
|
|
5
9
|
this.service = serviceID;
|
|
6
10
|
this.methods = methods;
|
|
@@ -9,6 +9,12 @@ import { combineUint8ArrayListTransform } from './array-list.js';
|
|
|
9
9
|
// Note: there is no way to know for sure when a MessagePort is closed!
|
|
10
10
|
// You will need an additional keep-alive on top of MessagePortDuplex.
|
|
11
11
|
export class MessagePortDuplex {
|
|
12
|
+
// port is the message port
|
|
13
|
+
port;
|
|
14
|
+
// sink is the sink for incoming messages.
|
|
15
|
+
sink;
|
|
16
|
+
// source is the source for outgoing messages.
|
|
17
|
+
source;
|
|
12
18
|
constructor(port) {
|
|
13
19
|
this.port = port;
|
|
14
20
|
this.sink = this._createSink();
|
|
@@ -73,6 +79,8 @@ export function newMessagePortDuplex(port) {
|
|
|
73
79
|
// expects Uint8Array objects over the MessagePort.
|
|
74
80
|
// uses Yamux to mux streams over the port.
|
|
75
81
|
export class MessagePortConn extends StreamConn {
|
|
82
|
+
// _messagePort is the message port iterable.
|
|
83
|
+
_messagePort;
|
|
76
84
|
constructor(port, server, connParams) {
|
|
77
85
|
const messagePort = new MessagePortDuplex(port);
|
|
78
86
|
super(server, {
|
package/dist/srpc/mux.js
CHANGED
|
@@ -5,13 +5,11 @@ export function createMux() {
|
|
|
5
5
|
// StaticMux contains a in-memory mapping between service ID and handlers.
|
|
6
6
|
// implements Mux
|
|
7
7
|
export class StaticMux {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.lookups = [];
|
|
14
|
-
}
|
|
8
|
+
// services contains a mapping from service id to handlers.
|
|
9
|
+
services = {};
|
|
10
|
+
// lookups is the list of lookup methods to call.
|
|
11
|
+
// called if the method is not resolved by the services list.
|
|
12
|
+
lookups = [];
|
|
15
13
|
// lookupMethodFunc implements the LookupMethod type.
|
|
16
14
|
get lookupMethodFunc() {
|
|
17
15
|
return this.lookupMethod.bind(this);
|
package/dist/srpc/rpcproto_pb.js
CHANGED
|
@@ -8,16 +8,29 @@ import { Message, proto3 } from '@bufbuild/protobuf';
|
|
|
8
8
|
* @generated from message srpc.Packet
|
|
9
9
|
*/
|
|
10
10
|
export class Packet extends Message {
|
|
11
|
+
/**
|
|
12
|
+
* Body is the packet body.
|
|
13
|
+
*
|
|
14
|
+
* @generated from oneof srpc.Packet.body
|
|
15
|
+
*/
|
|
16
|
+
body = { case: undefined };
|
|
11
17
|
constructor(data) {
|
|
12
18
|
super();
|
|
13
|
-
/**
|
|
14
|
-
* Body is the packet body.
|
|
15
|
-
*
|
|
16
|
-
* @generated from oneof srpc.Packet.body
|
|
17
|
-
*/
|
|
18
|
-
this.body = { case: undefined };
|
|
19
19
|
proto3.util.initPartial(data, this);
|
|
20
20
|
}
|
|
21
|
+
static runtime = proto3;
|
|
22
|
+
static typeName = 'srpc.Packet';
|
|
23
|
+
static fields = proto3.util.newFieldList(() => [
|
|
24
|
+
{ no: 1, name: 'call_start', kind: 'message', T: CallStart, oneof: 'body' },
|
|
25
|
+
{ no: 2, name: 'call_data', kind: 'message', T: CallData, oneof: 'body' },
|
|
26
|
+
{
|
|
27
|
+
no: 3,
|
|
28
|
+
name: 'call_cancel',
|
|
29
|
+
kind: 'scalar',
|
|
30
|
+
T: 8 /* ScalarType.BOOL */,
|
|
31
|
+
oneof: 'body',
|
|
32
|
+
},
|
|
33
|
+
]);
|
|
21
34
|
static fromBinary(bytes, options) {
|
|
22
35
|
return new Packet().fromBinary(bytes, options);
|
|
23
36
|
}
|
|
@@ -31,56 +44,56 @@ export class Packet extends Message {
|
|
|
31
44
|
return proto3.util.equals(Packet, a, b);
|
|
32
45
|
}
|
|
33
46
|
}
|
|
34
|
-
Packet.runtime = proto3;
|
|
35
|
-
Packet.typeName = 'srpc.Packet';
|
|
36
|
-
Packet.fields = proto3.util.newFieldList(() => [
|
|
37
|
-
{ no: 1, name: 'call_start', kind: 'message', T: CallStart, oneof: 'body' },
|
|
38
|
-
{ no: 2, name: 'call_data', kind: 'message', T: CallData, oneof: 'body' },
|
|
39
|
-
{
|
|
40
|
-
no: 3,
|
|
41
|
-
name: 'call_cancel',
|
|
42
|
-
kind: 'scalar',
|
|
43
|
-
T: 8 /* ScalarType.BOOL */,
|
|
44
|
-
oneof: 'body',
|
|
45
|
-
},
|
|
46
|
-
]);
|
|
47
47
|
/**
|
|
48
48
|
* CallStart requests starting a new RPC call.
|
|
49
49
|
*
|
|
50
50
|
* @generated from message srpc.CallStart
|
|
51
51
|
*/
|
|
52
52
|
export class CallStart extends Message {
|
|
53
|
+
/**
|
|
54
|
+
* RpcService is the service to contact.
|
|
55
|
+
* Must be set.
|
|
56
|
+
*
|
|
57
|
+
* @generated from field: string rpc_service = 1;
|
|
58
|
+
*/
|
|
59
|
+
rpcService = '';
|
|
60
|
+
/**
|
|
61
|
+
* RpcMethod is the RPC method to call.
|
|
62
|
+
* Must be set.
|
|
63
|
+
*
|
|
64
|
+
* @generated from field: string rpc_method = 2;
|
|
65
|
+
*/
|
|
66
|
+
rpcMethod = '';
|
|
67
|
+
/**
|
|
68
|
+
* Data contains the request or the first message in the stream.
|
|
69
|
+
* Optional if streaming.
|
|
70
|
+
*
|
|
71
|
+
* @generated from field: bytes data = 3;
|
|
72
|
+
*/
|
|
73
|
+
data = new Uint8Array(0);
|
|
74
|
+
/**
|
|
75
|
+
* DataIsZero indicates Data is set with an empty message.
|
|
76
|
+
*
|
|
77
|
+
* @generated from field: bool data_is_zero = 4;
|
|
78
|
+
*/
|
|
79
|
+
dataIsZero = false;
|
|
53
80
|
constructor(data) {
|
|
54
81
|
super();
|
|
55
|
-
/**
|
|
56
|
-
* RpcService is the service to contact.
|
|
57
|
-
* Must be set.
|
|
58
|
-
*
|
|
59
|
-
* @generated from field: string rpc_service = 1;
|
|
60
|
-
*/
|
|
61
|
-
this.rpcService = '';
|
|
62
|
-
/**
|
|
63
|
-
* RpcMethod is the RPC method to call.
|
|
64
|
-
* Must be set.
|
|
65
|
-
*
|
|
66
|
-
* @generated from field: string rpc_method = 2;
|
|
67
|
-
*/
|
|
68
|
-
this.rpcMethod = '';
|
|
69
|
-
/**
|
|
70
|
-
* Data contains the request or the first message in the stream.
|
|
71
|
-
* Optional if streaming.
|
|
72
|
-
*
|
|
73
|
-
* @generated from field: bytes data = 3;
|
|
74
|
-
*/
|
|
75
|
-
this.data = new Uint8Array(0);
|
|
76
|
-
/**
|
|
77
|
-
* DataIsZero indicates Data is set with an empty message.
|
|
78
|
-
*
|
|
79
|
-
* @generated from field: bool data_is_zero = 4;
|
|
80
|
-
*/
|
|
81
|
-
this.dataIsZero = false;
|
|
82
82
|
proto3.util.initPartial(data, this);
|
|
83
83
|
}
|
|
84
|
+
static runtime = proto3;
|
|
85
|
+
static typeName = 'srpc.CallStart';
|
|
86
|
+
static fields = proto3.util.newFieldList(() => [
|
|
87
|
+
{
|
|
88
|
+
no: 1,
|
|
89
|
+
name: 'rpc_service',
|
|
90
|
+
kind: 'scalar',
|
|
91
|
+
T: 9 /* ScalarType.STRING */,
|
|
92
|
+
},
|
|
93
|
+
{ no: 2, name: 'rpc_method', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
94
|
+
{ no: 3, name: 'data', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
|
|
95
|
+
{ no: 4, name: 'data_is_zero', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
|
|
96
|
+
]);
|
|
84
97
|
static fromBinary(bytes, options) {
|
|
85
98
|
return new CallStart().fromBinary(bytes, options);
|
|
86
99
|
}
|
|
@@ -94,54 +107,49 @@ export class CallStart extends Message {
|
|
|
94
107
|
return proto3.util.equals(CallStart, a, b);
|
|
95
108
|
}
|
|
96
109
|
}
|
|
97
|
-
CallStart.runtime = proto3;
|
|
98
|
-
CallStart.typeName = 'srpc.CallStart';
|
|
99
|
-
CallStart.fields = proto3.util.newFieldList(() => [
|
|
100
|
-
{
|
|
101
|
-
no: 1,
|
|
102
|
-
name: 'rpc_service',
|
|
103
|
-
kind: 'scalar',
|
|
104
|
-
T: 9 /* ScalarType.STRING */,
|
|
105
|
-
},
|
|
106
|
-
{ no: 2, name: 'rpc_method', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
107
|
-
{ no: 3, name: 'data', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
|
|
108
|
-
{ no: 4, name: 'data_is_zero', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
|
|
109
|
-
]);
|
|
110
110
|
/**
|
|
111
111
|
* CallData contains a message in a streaming RPC sequence.
|
|
112
112
|
*
|
|
113
113
|
* @generated from message srpc.CallData
|
|
114
114
|
*/
|
|
115
115
|
export class CallData extends Message {
|
|
116
|
+
/**
|
|
117
|
+
* Data contains the packet in the sequence.
|
|
118
|
+
*
|
|
119
|
+
* @generated from field: bytes data = 1;
|
|
120
|
+
*/
|
|
121
|
+
data = new Uint8Array(0);
|
|
122
|
+
/**
|
|
123
|
+
* DataIsZero indicates Data is set with an empty message.
|
|
124
|
+
*
|
|
125
|
+
* @generated from field: bool data_is_zero = 2;
|
|
126
|
+
*/
|
|
127
|
+
dataIsZero = false;
|
|
128
|
+
/**
|
|
129
|
+
* Complete indicates the RPC call is completed.
|
|
130
|
+
*
|
|
131
|
+
* @generated from field: bool complete = 3;
|
|
132
|
+
*/
|
|
133
|
+
complete = false;
|
|
134
|
+
/**
|
|
135
|
+
* Error contains any error that caused the RPC to fail.
|
|
136
|
+
* If set, implies complete=true.
|
|
137
|
+
*
|
|
138
|
+
* @generated from field: string error = 4;
|
|
139
|
+
*/
|
|
140
|
+
error = '';
|
|
116
141
|
constructor(data) {
|
|
117
142
|
super();
|
|
118
|
-
/**
|
|
119
|
-
* Data contains the packet in the sequence.
|
|
120
|
-
*
|
|
121
|
-
* @generated from field: bytes data = 1;
|
|
122
|
-
*/
|
|
123
|
-
this.data = new Uint8Array(0);
|
|
124
|
-
/**
|
|
125
|
-
* DataIsZero indicates Data is set with an empty message.
|
|
126
|
-
*
|
|
127
|
-
* @generated from field: bool data_is_zero = 2;
|
|
128
|
-
*/
|
|
129
|
-
this.dataIsZero = false;
|
|
130
|
-
/**
|
|
131
|
-
* Complete indicates the RPC call is completed.
|
|
132
|
-
*
|
|
133
|
-
* @generated from field: bool complete = 3;
|
|
134
|
-
*/
|
|
135
|
-
this.complete = false;
|
|
136
|
-
/**
|
|
137
|
-
* Error contains any error that caused the RPC to fail.
|
|
138
|
-
* If set, implies complete=true.
|
|
139
|
-
*
|
|
140
|
-
* @generated from field: string error = 4;
|
|
141
|
-
*/
|
|
142
|
-
this.error = '';
|
|
143
143
|
proto3.util.initPartial(data, this);
|
|
144
144
|
}
|
|
145
|
+
static runtime = proto3;
|
|
146
|
+
static typeName = 'srpc.CallData';
|
|
147
|
+
static fields = proto3.util.newFieldList(() => [
|
|
148
|
+
{ no: 1, name: 'data', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
|
|
149
|
+
{ no: 2, name: 'data_is_zero', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
|
|
150
|
+
{ no: 3, name: 'complete', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
|
|
151
|
+
{ no: 4, name: 'error', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
152
|
+
]);
|
|
145
153
|
static fromBinary(bytes, options) {
|
|
146
154
|
return new CallData().fromBinary(bytes, options);
|
|
147
155
|
}
|
|
@@ -155,11 +163,3 @@ export class CallData extends Message {
|
|
|
155
163
|
return proto3.util.equals(CallData, a, b);
|
|
156
164
|
}
|
|
157
165
|
}
|
|
158
|
-
CallData.runtime = proto3;
|
|
159
|
-
CallData.typeName = 'srpc.CallData';
|
|
160
|
-
CallData.fields = proto3.util.newFieldList(() => [
|
|
161
|
-
{ no: 1, name: 'data', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
|
|
162
|
-
{ no: 2, name: 'data_is_zero', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
|
|
163
|
-
{ no: 3, name: 'complete', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
|
|
164
|
-
{ no: 4, name: 'error', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
|
|
165
|
-
]);
|
package/dist/srpc/server-rpc.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { CommonRPC } from './common-rpc.js';
|
|
2
2
|
// ServerRPC is an ongoing RPC from the server side.
|
|
3
3
|
export class ServerRPC extends CommonRPC {
|
|
4
|
+
// lookupMethod looks up the incoming RPC methods.
|
|
5
|
+
lookupMethod;
|
|
4
6
|
constructor(lookupMethod) {
|
|
5
7
|
super();
|
|
6
8
|
this.lookupMethod = lookupMethod;
|
package/dist/srpc/server.js
CHANGED
|
@@ -3,6 +3,8 @@ import { ServerRPC } from './server-rpc.js';
|
|
|
3
3
|
import { decodePacketSource, encodePacketSource } from './packet.js';
|
|
4
4
|
// Server implements the SRPC server in TypeScript with a Mux.
|
|
5
5
|
export class Server {
|
|
6
|
+
// lookupMethod looks up the incoming RPC methods.
|
|
7
|
+
lookupMethod;
|
|
6
8
|
constructor(lookupMethod) {
|
|
7
9
|
this.lookupMethod = lookupMethod;
|
|
8
10
|
}
|
package/dist/srpc/value-ctr.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// ValueCtr contains a value that can be set asynchronously.
|
|
2
2
|
export class ValueCtr {
|
|
3
|
+
// _value contains the current value.
|
|
4
|
+
_value;
|
|
5
|
+
// _waiters contains the list of waiters.
|
|
6
|
+
// called when the value is set to any value other than undefined.
|
|
7
|
+
_waiters;
|
|
3
8
|
constructor(initialValue) {
|
|
4
9
|
this._value = initialValue || undefined;
|
|
5
10
|
this._waiters = [];
|
package/dist/srpc/watchdog.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
// Watchdog must be fed every timeoutDuration or it will call the expired callback.
|
|
2
2
|
// NOTE: Browsers will throttle setTimeout in background tabs.
|
|
3
3
|
export class Watchdog {
|
|
4
|
+
timeoutDuration;
|
|
5
|
+
expiredCallback;
|
|
6
|
+
timerId = null;
|
|
7
|
+
lastFeedTimestamp = null;
|
|
4
8
|
/**
|
|
5
9
|
* Constructs a Watchdog instance.
|
|
6
10
|
* The Watchdog will not start ticking until feed() is called.
|
|
@@ -8,8 +12,6 @@ export class Watchdog {
|
|
|
8
12
|
* @param expiredCallback The callback function to be called when the watchdog expires.
|
|
9
13
|
*/
|
|
10
14
|
constructor(timeoutDuration, expiredCallback) {
|
|
11
|
-
this.timerId = null;
|
|
12
|
-
this.lastFeedTimestamp = null;
|
|
13
15
|
this.timeoutDuration = timeoutDuration;
|
|
14
16
|
this.expiredCallback = expiredCallback;
|
|
15
17
|
}
|
package/dist/srpc/websocket.js
CHANGED
|
@@ -4,6 +4,8 @@ import { StreamConn } from './conn.js';
|
|
|
4
4
|
import { combineUint8ArrayListTransform } from './array-list.js';
|
|
5
5
|
// WebSocketConn implements a connection with a WebSocket and optional Server.
|
|
6
6
|
export class WebSocketConn extends StreamConn {
|
|
7
|
+
// socket is the web socket
|
|
8
|
+
socket;
|
|
7
9
|
constructor(socket, direction, server) {
|
|
8
10
|
super(server, { direction });
|
|
9
11
|
this.socket = socket;
|
package/e2e/mock/mock.pb.go
CHANGED
package/e2e/mock/mock_srpc.pb.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-starpc
|
|
1
|
+
// @generated by protoc-gen-es-starpc none with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/e2e/mock/mock.proto (package e2e.mock, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
package/echo/echo.pb.go
CHANGED
package/echo/echo_srpc.pb.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @generated by protoc-gen-es-starpc
|
|
1
|
+
// @generated by protoc-gen-es-starpc none with parameter "target=ts,ts_nocheck=false"
|
|
2
2
|
// @generated from file github.com/aperturerobotics/starpc/echo/echo.proto (package echo, syntax proto3)
|
|
3
3
|
/* eslint-disable */
|
|
4
4
|
|
package/go.mod
CHANGED
package/go.sum
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
github.com/aperturerobotics/protobuf-go-lite v0.4.
|
|
2
|
-
github.com/aperturerobotics/protobuf-go-lite v0.4.
|
|
1
|
+
github.com/aperturerobotics/protobuf-go-lite v0.4.3 h1:QDoO0ytzO71UWSPbaPi4XF5LfKYDJYxIBlimjYOh5nY=
|
|
2
|
+
github.com/aperturerobotics/protobuf-go-lite v0.4.3/go.mod h1:wRZn4YydbTn8Bdx4NB6ms0doF19llgim+0SNBvQ7M9c=
|
|
3
3
|
github.com/aperturerobotics/util v1.17.1 h1:7qG1Am+vNAelbXCdYOYfnMaZKM28QBWVCi+zvkjo+d4=
|
|
4
4
|
github.com/aperturerobotics/util v1.17.1/go.mod h1:NdGzI+NyJvqEwt+RkKPxOlKl9zUSWJMgKicNci7ZFMU=
|
|
5
5
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starpc",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.2",
|
|
4
4
|
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
"url": "http://github.com/paralin"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
|
+
"type": "module",
|
|
18
19
|
"main": "./dist/index.js",
|
|
19
20
|
"types": "./dist/index.d.ts",
|
|
20
21
|
"bin": {
|
|
@@ -57,7 +58,7 @@
|
|
|
57
58
|
"integration": "npm run test:integration",
|
|
58
59
|
"lint": "npm run lint:go && npm run lint:js",
|
|
59
60
|
"lint:go": "make lint",
|
|
60
|
-
"lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint -c .eslintrc.
|
|
61
|
+
"lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint -c .eslintrc.cjs --ignore-pattern *.js --ignore-pattern *.d.ts ./",
|
|
61
62
|
"prepare": "go mod vendor",
|
|
62
63
|
"precommit": "npm run format"
|
|
63
64
|
},
|
package/srpc/rpcproto.pb.go
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Code generated by protoc-gen-go-lite. DO NOT EDIT.
|
|
2
|
-
// protoc-gen-go-lite version: v0.4.
|
|
2
|
+
// protoc-gen-go-lite version: v0.4.3
|
|
3
3
|
// source: github.com/aperturerobotics/starpc/srpc/rpcproto.proto
|
|
4
4
|
|
|
5
5
|
package srpc
|
|
@@ -89,15 +89,15 @@ type CallStart struct {
|
|
|
89
89
|
unknownFields []byte
|
|
90
90
|
// RpcService is the service to contact.
|
|
91
91
|
// Must be set.
|
|
92
|
-
RpcService string `protobuf:"bytes,1,opt,name=rpc_service,json=rpcService,proto3" json:"
|
|
92
|
+
RpcService string `protobuf:"bytes,1,opt,name=rpc_service,json=rpcService,proto3" json:"rpcService,omitempty"`
|
|
93
93
|
// RpcMethod is the RPC method to call.
|
|
94
94
|
// Must be set.
|
|
95
|
-
RpcMethod string `protobuf:"bytes,2,opt,name=rpc_method,json=rpcMethod,proto3" json:"
|
|
95
|
+
RpcMethod string `protobuf:"bytes,2,opt,name=rpc_method,json=rpcMethod,proto3" json:"rpcMethod,omitempty"`
|
|
96
96
|
// Data contains the request or the first message in the stream.
|
|
97
97
|
// Optional if streaming.
|
|
98
98
|
Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
|
|
99
99
|
// DataIsZero indicates Data is set with an empty message.
|
|
100
|
-
DataIsZero bool `protobuf:"varint,4,opt,name=data_is_zero,json=dataIsZero,proto3" json:"
|
|
100
|
+
DataIsZero bool `protobuf:"varint,4,opt,name=data_is_zero,json=dataIsZero,proto3" json:"dataIsZero,omitempty"`
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
func (x *CallStart) Reset() {
|
|
@@ -140,7 +140,7 @@ type CallData struct {
|
|
|
140
140
|
// Data contains the packet in the sequence.
|
|
141
141
|
Data []byte `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"`
|
|
142
142
|
// DataIsZero indicates Data is set with an empty message.
|
|
143
|
-
DataIsZero bool `protobuf:"varint,2,opt,name=data_is_zero,json=dataIsZero,proto3" json:"
|
|
143
|
+
DataIsZero bool `protobuf:"varint,2,opt,name=data_is_zero,json=dataIsZero,proto3" json:"dataIsZero,omitempty"`
|
|
144
144
|
// Complete indicates the RPC call is completed.
|
|
145
145
|
Complete bool `protobuf:"varint,3,opt,name=complete,proto3" json:"complete,omitempty"`
|
|
146
146
|
// Error contains any error that caused the RPC to fail.
|
|
@@ -438,15 +438,15 @@ func (x *Packet) MarshalProtoJSON(s *json.MarshalState) {
|
|
|
438
438
|
switch ov := x.Body.(type) {
|
|
439
439
|
case *Packet_CallStart:
|
|
440
440
|
s.WriteMoreIf(&wroteField)
|
|
441
|
-
s.WriteObjectField("
|
|
442
|
-
ov.CallStart.MarshalProtoJSON(s.WithField("
|
|
441
|
+
s.WriteObjectField("callStart")
|
|
442
|
+
ov.CallStart.MarshalProtoJSON(s.WithField("callStart"))
|
|
443
443
|
case *Packet_CallData:
|
|
444
444
|
s.WriteMoreIf(&wroteField)
|
|
445
|
-
s.WriteObjectField("
|
|
446
|
-
ov.CallData.MarshalProtoJSON(s.WithField("
|
|
445
|
+
s.WriteObjectField("callData")
|
|
446
|
+
ov.CallData.MarshalProtoJSON(s.WithField("callData"))
|
|
447
447
|
case *Packet_CallCancel:
|
|
448
448
|
s.WriteMoreIf(&wroteField)
|
|
449
|
-
s.WriteObjectField("
|
|
449
|
+
s.WriteObjectField("callCancel")
|
|
450
450
|
s.WriteBool(ov.CallCancel)
|
|
451
451
|
}
|
|
452
452
|
}
|
|
@@ -507,14 +507,14 @@ func (x *CallStart) MarshalProtoJSON(s *json.MarshalState) {
|
|
|
507
507
|
}
|
|
508
508
|
s.WriteObjectStart()
|
|
509
509
|
var wroteField bool
|
|
510
|
-
if x.RpcService != "" || s.HasField("
|
|
510
|
+
if x.RpcService != "" || s.HasField("rpcService") {
|
|
511
511
|
s.WriteMoreIf(&wroteField)
|
|
512
|
-
s.WriteObjectField("
|
|
512
|
+
s.WriteObjectField("rpcService")
|
|
513
513
|
s.WriteString(x.RpcService)
|
|
514
514
|
}
|
|
515
|
-
if x.RpcMethod != "" || s.HasField("
|
|
515
|
+
if x.RpcMethod != "" || s.HasField("rpcMethod") {
|
|
516
516
|
s.WriteMoreIf(&wroteField)
|
|
517
|
-
s.WriteObjectField("
|
|
517
|
+
s.WriteObjectField("rpcMethod")
|
|
518
518
|
s.WriteString(x.RpcMethod)
|
|
519
519
|
}
|
|
520
520
|
if len(x.Data) > 0 || s.HasField("data") {
|
|
@@ -522,9 +522,9 @@ func (x *CallStart) MarshalProtoJSON(s *json.MarshalState) {
|
|
|
522
522
|
s.WriteObjectField("data")
|
|
523
523
|
s.WriteBytes(x.Data)
|
|
524
524
|
}
|
|
525
|
-
if x.DataIsZero || s.HasField("
|
|
525
|
+
if x.DataIsZero || s.HasField("dataIsZero") {
|
|
526
526
|
s.WriteMoreIf(&wroteField)
|
|
527
|
-
s.WriteObjectField("
|
|
527
|
+
s.WriteObjectField("dataIsZero")
|
|
528
528
|
s.WriteBool(x.DataIsZero)
|
|
529
529
|
}
|
|
530
530
|
s.WriteObjectEnd()
|
|
@@ -578,9 +578,9 @@ func (x *CallData) MarshalProtoJSON(s *json.MarshalState) {
|
|
|
578
578
|
s.WriteObjectField("data")
|
|
579
579
|
s.WriteBytes(x.Data)
|
|
580
580
|
}
|
|
581
|
-
if x.DataIsZero || s.HasField("
|
|
581
|
+
if x.DataIsZero || s.HasField("dataIsZero") {
|
|
582
582
|
s.WriteMoreIf(&wroteField)
|
|
583
|
-
s.WriteObjectField("
|
|
583
|
+
s.WriteObjectField("dataIsZero")
|
|
584
584
|
s.WriteBool(x.DataIsZero)
|
|
585
585
|
}
|
|
586
586
|
if x.Complete || s.HasField("complete") {
|
package/dist/package.json
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "starpc",
|
|
3
|
-
"version": "0.31.0",
|
|
4
|
-
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
|
-
"license": "MIT",
|
|
6
|
-
"author": {
|
|
7
|
-
"name": "Aperture Robotics LLC.",
|
|
8
|
-
"email": "support@aperture.us",
|
|
9
|
-
"url": "http://aperture.us"
|
|
10
|
-
},
|
|
11
|
-
"contributors": [
|
|
12
|
-
{
|
|
13
|
-
"name": "Christian Stewart",
|
|
14
|
-
"email": "christian@aperture.us",
|
|
15
|
-
"url": "http://github.com/paralin"
|
|
16
|
-
}
|
|
17
|
-
],
|
|
18
|
-
"main": "./dist/index.js",
|
|
19
|
-
"types": "./dist/index.d.ts",
|
|
20
|
-
"bin": {
|
|
21
|
-
"protoc-gen-es-starpc": "./cmd/protoc-gen-es-starpc/protoc-gen-es-starpc"
|
|
22
|
-
},
|
|
23
|
-
"files": [
|
|
24
|
-
"!**/*.tsbuildinfo",
|
|
25
|
-
"Makefile",
|
|
26
|
-
"dist",
|
|
27
|
-
"e2e",
|
|
28
|
-
"echo",
|
|
29
|
-
"go.mod",
|
|
30
|
-
"go.sum",
|
|
31
|
-
"integration",
|
|
32
|
-
"srpc",
|
|
33
|
-
"cmd/protoc-gen-es-starpc"
|
|
34
|
-
],
|
|
35
|
-
"repository": {
|
|
36
|
-
"url": "git+ssh://git@github.com/aperturerobotics/starpc.git"
|
|
37
|
-
},
|
|
38
|
-
"scripts": {
|
|
39
|
-
"clean": "rimraf ./dist",
|
|
40
|
-
"build": "npm run clean && tsc --project tsconfig.build.json --outDir ./dist/",
|
|
41
|
-
"check": "npm run typecheck",
|
|
42
|
-
"typecheck": "tsc --noEmit",
|
|
43
|
-
"deps": "depcheck --ignores 'bufferutil,utf-8-validate,rimraf,starpc,@bufbuild/protoc-gen-es,tsx'",
|
|
44
|
-
"codegen": "npm run gen",
|
|
45
|
-
"ci": "npm run build && npm run lint:js && npm run lint:go",
|
|
46
|
-
"format": "npm run format:go && npm run format:js && npm run format:config",
|
|
47
|
-
"format:config": "prettier --write tsconfig.json package.json",
|
|
48
|
-
"format:go": "make format",
|
|
49
|
-
"format:js": "prettier --write './{srpc,echo,e2e,integration,rpcstream,cmd}/**/(*.ts|*.tsx|*.html|*.css)'",
|
|
50
|
-
"gen": "make genproto",
|
|
51
|
-
"test": "npm run test:js && npm run test:go",
|
|
52
|
-
"test:go": "make test",
|
|
53
|
-
"build:e2e": "npm run build && cd e2e && esbuild e2e.ts --sourcemap --outfile=e2e.js --bundle --platform=node",
|
|
54
|
-
"test:js": "npm run build:e2e && cd e2e && node ./e2e.js",
|
|
55
|
-
"debug:js": "npm run build:e2e && cd e2e && node --inspect --inspect-brk ./e2e.js",
|
|
56
|
-
"test:integration": "make integration",
|
|
57
|
-
"integration": "npm run test:integration",
|
|
58
|
-
"lint": "npm run lint:go && npm run lint:js",
|
|
59
|
-
"lint:go": "make lint",
|
|
60
|
-
"lint:js": "ESLINT_USE_FLAT_CONFIG=false eslint -c .eslintrc.js --ignore-pattern *.js --ignore-pattern *.d.ts ./",
|
|
61
|
-
"prepare": "go mod vendor",
|
|
62
|
-
"precommit": "npm run format"
|
|
63
|
-
},
|
|
64
|
-
"prettier": {
|
|
65
|
-
"semi": false,
|
|
66
|
-
"singleQuote": true
|
|
67
|
-
},
|
|
68
|
-
"devDependencies": {
|
|
69
|
-
"@bufbuild/protoc-gen-es": "^1.8.0",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^7.7.0",
|
|
71
|
-
"@typescript-eslint/parser": "^7.7.0",
|
|
72
|
-
"bufferutil": "^4.0.7",
|
|
73
|
-
"depcheck": "^1.4.6",
|
|
74
|
-
"esbuild": "^0.20.0",
|
|
75
|
-
"eslint": "^9.1.0",
|
|
76
|
-
"eslint-config-prettier": "^9.1.0",
|
|
77
|
-
"prettier": "^3.2.4",
|
|
78
|
-
"rimraf": "^5.0.1",
|
|
79
|
-
"tsx": "^4.7.2",
|
|
80
|
-
"typescript": "^5.3.2",
|
|
81
|
-
"utf-8-validate": "^6.0.3"
|
|
82
|
-
},
|
|
83
|
-
"dependencies": {
|
|
84
|
-
"@aptre/it-ws": "^1.0.0",
|
|
85
|
-
"@bufbuild/protobuf": "^1.8.0",
|
|
86
|
-
"@bufbuild/protoplugin": "^1.8.0",
|
|
87
|
-
"@chainsafe/libp2p-yamux": "^6.0.2",
|
|
88
|
-
"@libp2p/interface": "^1.1.3",
|
|
89
|
-
"@libp2p/logger": "^4.0.6",
|
|
90
|
-
"event-iterator": "^2.0.0",
|
|
91
|
-
"isomorphic-ws": "^5.0.0",
|
|
92
|
-
"it-first": "^3.0.3",
|
|
93
|
-
"it-pipe": "^3.0.1",
|
|
94
|
-
"it-pushable": "^3.2.3",
|
|
95
|
-
"it-stream-types": "^2.0.1",
|
|
96
|
-
"memoize-one": "^6.0.0",
|
|
97
|
-
"uint8arraylist": "^2.4.7",
|
|
98
|
-
"ws": "^8.15.1"
|
|
99
|
-
}
|
|
100
|
-
}
|