starpc 0.27.2 → 0.28.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.
- package/Makefile +18 -8
- package/dist/e2e/mock/mock.pb.d.ts +3 -3
- package/dist/echo/echo.pb.d.ts +9 -9
- package/dist/rpcstream/rpcstream.pb.d.ts +3 -3
- package/dist/srpc/channel.js +0 -1
- package/dist/srpc/rpcproto.pb.d.ts +3 -3
- package/dist/srpc/rpcproto.pb.js +6 -6
- package/e2e/mock/mock.pb.go +1 -1
- package/echo/echo.pb.go +1 -1
- package/go.mod +10 -8
- package/go.sum +14 -16
- package/integration/integration.go +8 -2
- package/package.json +4 -2
- package/srpc/channel.ts +0 -1
- package/srpc/pushable_js.go +48 -0
- package/srpc/rpcproto.pb.go +1 -1
- package/srpc/rpcproto.pb.ts +6 -6
package/Makefile
CHANGED
|
@@ -6,13 +6,14 @@ PROTOC_GEN_GO=hack/bin/protoc-gen-go
|
|
|
6
6
|
PROTOC_GEN_STARPC=hack/bin/protoc-gen-go-starpc
|
|
7
7
|
PROTOC_GEN_VTPROTO=hack/bin/protoc-gen-go-vtproto
|
|
8
8
|
GOIMPORTS=hack/bin/goimports
|
|
9
|
+
GOFUMPT=hack/bin/gofumpt
|
|
9
10
|
GOLANGCI_LINT=hack/bin/golangci-lint
|
|
10
11
|
GO_MOD_OUTDATED=hack/bin/go-mod-outdated
|
|
11
12
|
GOLIST=go list -f "{{ .Dir }}" -m
|
|
12
13
|
|
|
13
14
|
export GO111MODULE=on
|
|
14
|
-
undefine GOARCH
|
|
15
15
|
undefine GOOS
|
|
16
|
+
undefine GOARCH
|
|
16
17
|
|
|
17
18
|
all:
|
|
18
19
|
|
|
@@ -43,6 +44,12 @@ $(GOIMPORTS):
|
|
|
43
44
|
-o ./bin/goimports \
|
|
44
45
|
golang.org/x/tools/cmd/goimports
|
|
45
46
|
|
|
47
|
+
$(GOFUMPT):
|
|
48
|
+
cd ./hack; \
|
|
49
|
+
go build -v \
|
|
50
|
+
-o ./bin/gofumpt \
|
|
51
|
+
mvdan.cc/gofumpt
|
|
52
|
+
|
|
46
53
|
$(PROTOWRAP):
|
|
47
54
|
cd ./hack; \
|
|
48
55
|
go build -v \
|
|
@@ -63,7 +70,6 @@ $(GO_MOD_OUTDATED):
|
|
|
63
70
|
|
|
64
71
|
.PHONY: gengo
|
|
65
72
|
gengo: $(GOIMPORTS) $(PROTOWRAP) $(PROTOC_GEN_GO) $(PROTOC_GEN_VTPROTO) $(PROTOC_GEN_STARPC)
|
|
66
|
-
go mod vendor
|
|
67
73
|
shopt -s globstar; \
|
|
68
74
|
set -eo pipefail; \
|
|
69
75
|
export PROJECT=$$(go list -m); \
|
|
@@ -93,7 +99,6 @@ node_modules:
|
|
|
93
99
|
|
|
94
100
|
.PHONY: gents
|
|
95
101
|
gents: $(PROTOWRAP) node_modules
|
|
96
|
-
go mod vendor
|
|
97
102
|
shopt -s globstar; \
|
|
98
103
|
set -eo pipefail; \
|
|
99
104
|
export PROJECT=$$(go list -m); \
|
|
@@ -121,9 +126,9 @@ gents: $(PROTOWRAP) node_modules
|
|
|
121
126
|
git \
|
|
122
127
|
ls-files "*.proto" |\
|
|
123
128
|
xargs printf -- \
|
|
124
|
-
"$$(pwd)/vendor/$${PROJECT}/%s ");
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
"$$(pwd)/vendor/$${PROJECT}/%s "); \
|
|
130
|
+
rm $$(pwd)/vendor/$${PROJECT} || true
|
|
131
|
+
npm run format:js
|
|
127
132
|
|
|
128
133
|
.PHONY: genproto
|
|
129
134
|
genproto: gengo gents
|
|
@@ -141,11 +146,16 @@ list: $(GO_MOD_OUTDATED)
|
|
|
141
146
|
|
|
142
147
|
.PHONY: lint
|
|
143
148
|
lint: $(GOLANGCI_LINT)
|
|
144
|
-
$(GOLANGCI_LINT) run
|
|
149
|
+
$(GOLANGCI_LINT) run --timeout=10m
|
|
145
150
|
|
|
146
151
|
.PHONY: fix
|
|
147
152
|
fix: $(GOLANGCI_LINT)
|
|
148
|
-
$(GOLANGCI_LINT) run --fix
|
|
153
|
+
$(GOLANGCI_LINT) run --fix --timeout=10m
|
|
154
|
+
|
|
155
|
+
.PHONY: format
|
|
156
|
+
format: $(GOFUMPT) $(GOIMPORTS)
|
|
157
|
+
$(GOIMPORTS) -w ./
|
|
158
|
+
$(GOFUMPT) -w ./
|
|
149
159
|
|
|
150
160
|
.PHONY: test
|
|
151
161
|
test:
|
|
@@ -16,7 +16,7 @@ export declare const MockMsg: {
|
|
|
16
16
|
body?: string | undefined;
|
|
17
17
|
} & {
|
|
18
18
|
body?: string | undefined;
|
|
19
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
19
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): MockMsg;
|
|
20
20
|
fromPartial<I_1 extends {
|
|
21
21
|
body?: string | undefined;
|
|
22
22
|
} & {
|
|
@@ -57,7 +57,7 @@ export declare const MockDefinition: {
|
|
|
57
57
|
body?: string | undefined;
|
|
58
58
|
} & {
|
|
59
59
|
body?: string | undefined;
|
|
60
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
60
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): MockMsg;
|
|
61
61
|
fromPartial<I_1 extends {
|
|
62
62
|
body?: string | undefined;
|
|
63
63
|
} & {
|
|
@@ -76,7 +76,7 @@ export declare const MockDefinition: {
|
|
|
76
76
|
body?: string | undefined;
|
|
77
77
|
} & {
|
|
78
78
|
body?: string | undefined;
|
|
79
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
79
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): MockMsg;
|
|
80
80
|
fromPartial<I_1 extends {
|
|
81
81
|
body?: string | undefined;
|
|
82
82
|
} & {
|
package/dist/echo/echo.pb.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare const EchoMsg: {
|
|
|
17
17
|
body?: string | undefined;
|
|
18
18
|
} & {
|
|
19
19
|
body?: string | undefined;
|
|
20
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
20
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
|
|
21
21
|
fromPartial<I_1 extends {
|
|
22
22
|
body?: string | undefined;
|
|
23
23
|
} & {
|
|
@@ -70,7 +70,7 @@ export declare const EchoerDefinition: {
|
|
|
70
70
|
body?: string | undefined;
|
|
71
71
|
} & {
|
|
72
72
|
body?: string | undefined;
|
|
73
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
73
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
|
|
74
74
|
fromPartial<I_1 extends {
|
|
75
75
|
body?: string | undefined;
|
|
76
76
|
} & {
|
|
@@ -89,7 +89,7 @@ export declare const EchoerDefinition: {
|
|
|
89
89
|
body?: string | undefined;
|
|
90
90
|
} & {
|
|
91
91
|
body?: string | undefined;
|
|
92
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
92
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
|
|
93
93
|
fromPartial<I_1 extends {
|
|
94
94
|
body?: string | undefined;
|
|
95
95
|
} & {
|
|
@@ -113,7 +113,7 @@ export declare const EchoerDefinition: {
|
|
|
113
113
|
body?: string | undefined;
|
|
114
114
|
} & {
|
|
115
115
|
body?: string | undefined;
|
|
116
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
116
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
|
|
117
117
|
fromPartial<I_1 extends {
|
|
118
118
|
body?: string | undefined;
|
|
119
119
|
} & {
|
|
@@ -132,7 +132,7 @@ export declare const EchoerDefinition: {
|
|
|
132
132
|
body?: string | undefined;
|
|
133
133
|
} & {
|
|
134
134
|
body?: string | undefined;
|
|
135
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
135
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
|
|
136
136
|
fromPartial<I_1 extends {
|
|
137
137
|
body?: string | undefined;
|
|
138
138
|
} & {
|
|
@@ -156,7 +156,7 @@ export declare const EchoerDefinition: {
|
|
|
156
156
|
body?: string | undefined;
|
|
157
157
|
} & {
|
|
158
158
|
body?: string | undefined;
|
|
159
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
159
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
|
|
160
160
|
fromPartial<I_1 extends {
|
|
161
161
|
body?: string | undefined;
|
|
162
162
|
} & {
|
|
@@ -175,7 +175,7 @@ export declare const EchoerDefinition: {
|
|
|
175
175
|
body?: string | undefined;
|
|
176
176
|
} & {
|
|
177
177
|
body?: string | undefined;
|
|
178
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
178
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
|
|
179
179
|
fromPartial<I_1 extends {
|
|
180
180
|
body?: string | undefined;
|
|
181
181
|
} & {
|
|
@@ -199,7 +199,7 @@ export declare const EchoerDefinition: {
|
|
|
199
199
|
body?: string | undefined;
|
|
200
200
|
} & {
|
|
201
201
|
body?: string | undefined;
|
|
202
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
202
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
|
|
203
203
|
fromPartial<I_1 extends {
|
|
204
204
|
body?: string | undefined;
|
|
205
205
|
} & {
|
|
@@ -218,7 +218,7 @@ export declare const EchoerDefinition: {
|
|
|
218
218
|
body?: string | undefined;
|
|
219
219
|
} & {
|
|
220
220
|
body?: string | undefined;
|
|
221
|
-
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
221
|
+
} & { [K in Exclude<keyof I, "body">]: never; }>(base?: I): EchoMsg;
|
|
222
222
|
fromPartial<I_1 extends {
|
|
223
223
|
body?: string | undefined;
|
|
224
224
|
} & {
|
|
@@ -84,7 +84,7 @@ export declare const RpcStreamPacket: {
|
|
|
84
84
|
data?: Uint8Array | undefined;
|
|
85
85
|
$case: "data";
|
|
86
86
|
} & { [K_4 in Exclude<keyof I["body"], "$case" | "data">]: never; }) | undefined;
|
|
87
|
-
} & { [K_5 in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
87
|
+
} & { [K_5 in Exclude<keyof I, "body">]: never; }>(base?: I): RpcStreamPacket;
|
|
88
88
|
fromPartial<I_1 extends {
|
|
89
89
|
body?: ({
|
|
90
90
|
init?: {
|
|
@@ -151,7 +151,7 @@ export declare const RpcStreamInit: {
|
|
|
151
151
|
componentId?: string | undefined;
|
|
152
152
|
} & {
|
|
153
153
|
componentId?: string | undefined;
|
|
154
|
-
} & { [K in Exclude<keyof I, "componentId">]: never; }>(base?: I
|
|
154
|
+
} & { [K in Exclude<keyof I, "componentId">]: never; }>(base?: I): RpcStreamInit;
|
|
155
155
|
fromPartial<I_1 extends {
|
|
156
156
|
componentId?: string | undefined;
|
|
157
157
|
} & {
|
|
@@ -169,7 +169,7 @@ export declare const RpcAck: {
|
|
|
169
169
|
error?: string | undefined;
|
|
170
170
|
} & {
|
|
171
171
|
error?: string | undefined;
|
|
172
|
-
} & { [K in Exclude<keyof I, "error">]: never; }>(base?: I
|
|
172
|
+
} & { [K in Exclude<keyof I, "error">]: never; }>(base?: I): RpcAck;
|
|
173
173
|
fromPartial<I_1 extends {
|
|
174
174
|
error?: string | undefined;
|
|
175
175
|
} & {
|
package/dist/srpc/channel.js
CHANGED
|
@@ -132,7 +132,7 @@ export declare const Packet: {
|
|
|
132
132
|
callCancel?: boolean | undefined;
|
|
133
133
|
$case: "callCancel";
|
|
134
134
|
} & { [K_4 in Exclude<keyof I["body"], "callCancel" | "$case">]: never; }) | undefined;
|
|
135
|
-
} & { [K_5 in Exclude<keyof I, "body">]: never; }>(base?: I
|
|
135
|
+
} & { [K_5 in Exclude<keyof I, "body">]: never; }>(base?: I): Packet;
|
|
136
136
|
fromPartial<I_1 extends {
|
|
137
137
|
body?: ({
|
|
138
138
|
callStart?: {
|
|
@@ -229,7 +229,7 @@ export declare const CallStart: {
|
|
|
229
229
|
rpcMethod?: string | undefined;
|
|
230
230
|
data?: Uint8Array | undefined;
|
|
231
231
|
dataIsZero?: boolean | undefined;
|
|
232
|
-
} & { [K in Exclude<keyof I, keyof CallStart>]: never; }>(base?: I
|
|
232
|
+
} & { [K in Exclude<keyof I, keyof CallStart>]: never; }>(base?: I): CallStart;
|
|
233
233
|
fromPartial<I_1 extends {
|
|
234
234
|
rpcService?: string | undefined;
|
|
235
235
|
rpcMethod?: string | undefined;
|
|
@@ -259,7 +259,7 @@ export declare const CallData: {
|
|
|
259
259
|
dataIsZero?: boolean | undefined;
|
|
260
260
|
complete?: boolean | undefined;
|
|
261
261
|
error?: string | undefined;
|
|
262
|
-
} & { [K in Exclude<keyof I, keyof CallData>]: never; }>(base?: I
|
|
262
|
+
} & { [K in Exclude<keyof I, keyof CallData>]: never; }>(base?: I): CallData;
|
|
263
263
|
fromPartial<I_1 extends {
|
|
264
264
|
data?: Uint8Array | undefined;
|
|
265
265
|
dataIsZero?: boolean | undefined;
|
package/dist/srpc/rpcproto.pb.js
CHANGED
|
@@ -165,7 +165,7 @@ export const CallStart = {
|
|
|
165
165
|
if (message.data.length !== 0) {
|
|
166
166
|
writer.uint32(26).bytes(message.data);
|
|
167
167
|
}
|
|
168
|
-
if (message.dataIsZero
|
|
168
|
+
if (message.dataIsZero !== false) {
|
|
169
169
|
writer.uint32(32).bool(message.dataIsZero);
|
|
170
170
|
}
|
|
171
171
|
return writer;
|
|
@@ -264,7 +264,7 @@ export const CallStart = {
|
|
|
264
264
|
if (message.data.length !== 0) {
|
|
265
265
|
obj.data = base64FromBytes(message.data);
|
|
266
266
|
}
|
|
267
|
-
if (message.dataIsZero
|
|
267
|
+
if (message.dataIsZero !== false) {
|
|
268
268
|
obj.dataIsZero = message.dataIsZero;
|
|
269
269
|
}
|
|
270
270
|
return obj;
|
|
@@ -294,10 +294,10 @@ export const CallData = {
|
|
|
294
294
|
if (message.data.length !== 0) {
|
|
295
295
|
writer.uint32(10).bytes(message.data);
|
|
296
296
|
}
|
|
297
|
-
if (message.dataIsZero
|
|
297
|
+
if (message.dataIsZero !== false) {
|
|
298
298
|
writer.uint32(16).bool(message.dataIsZero);
|
|
299
299
|
}
|
|
300
|
-
if (message.complete
|
|
300
|
+
if (message.complete !== false) {
|
|
301
301
|
writer.uint32(24).bool(message.complete);
|
|
302
302
|
}
|
|
303
303
|
if (message.error !== '') {
|
|
@@ -391,10 +391,10 @@ export const CallData = {
|
|
|
391
391
|
if (message.data.length !== 0) {
|
|
392
392
|
obj.data = base64FromBytes(message.data);
|
|
393
393
|
}
|
|
394
|
-
if (message.dataIsZero
|
|
394
|
+
if (message.dataIsZero !== false) {
|
|
395
395
|
obj.dataIsZero = message.dataIsZero;
|
|
396
396
|
}
|
|
397
|
-
if (message.complete
|
|
397
|
+
if (message.complete !== false) {
|
|
398
398
|
obj.complete = message.complete;
|
|
399
399
|
}
|
|
400
400
|
if (message.error !== '') {
|
package/e2e/mock/mock.pb.go
CHANGED
package/echo/echo.pb.go
CHANGED
package/go.mod
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
module github.com/aperturerobotics/starpc
|
|
2
2
|
|
|
3
|
-
go 1.
|
|
3
|
+
go 1.22
|
|
4
|
+
|
|
5
|
+
toolchain go1.22.1
|
|
4
6
|
|
|
5
7
|
require (
|
|
6
8
|
github.com/pkg/errors v0.9.1 // latest
|
|
7
|
-
google.golang.org/protobuf v1.
|
|
9
|
+
google.golang.org/protobuf v1.33.0 // latest
|
|
8
10
|
nhooyr.io/websocket v1.8.10 // latest
|
|
9
11
|
)
|
|
10
12
|
|
|
11
13
|
require (
|
|
12
|
-
github.com/aperturerobotics/util v1.
|
|
13
|
-
github.com/libp2p/go-libp2p v0.33.
|
|
14
|
-
github.com/libp2p/go-yamux/v4 v4.0.2-0.
|
|
14
|
+
github.com/aperturerobotics/util v1.16.0 // latest
|
|
15
|
+
github.com/libp2p/go-libp2p v0.33.2 // latest
|
|
16
|
+
github.com/libp2p/go-yamux/v4 v4.0.2-0.20240322071716-53ef5820bd48 // master
|
|
15
17
|
github.com/sirupsen/logrus v1.9.3 // latest
|
|
16
18
|
)
|
|
17
19
|
|
|
@@ -26,7 +28,7 @@ require (
|
|
|
26
28
|
github.com/mr-tron/base58 v1.2.0 // indirect
|
|
27
29
|
github.com/multiformats/go-base32 v0.1.0 // indirect
|
|
28
30
|
github.com/multiformats/go-base36 v0.2.0 // indirect
|
|
29
|
-
github.com/multiformats/go-multiaddr v0.12.
|
|
31
|
+
github.com/multiformats/go-multiaddr v0.12.3 // indirect
|
|
30
32
|
github.com/multiformats/go-multibase v0.2.0 // indirect
|
|
31
33
|
github.com/multiformats/go-multicodec v0.9.0 // indirect
|
|
32
34
|
github.com/multiformats/go-multihash v0.2.3 // indirect
|
|
@@ -34,7 +36,7 @@ require (
|
|
|
34
36
|
github.com/multiformats/go-varint v0.0.7 // indirect
|
|
35
37
|
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
|
36
38
|
golang.org/x/crypto v0.19.0 // indirect
|
|
37
|
-
golang.org/x/exp v0.0.0-
|
|
38
|
-
golang.org/x/sys v0.
|
|
39
|
+
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
|
|
40
|
+
golang.org/x/sys v0.18.0 // indirect
|
|
39
41
|
lukechampine.com/blake3 v1.2.1 // indirect
|
|
40
42
|
)
|
package/go.sum
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
github.com/aperturerobotics/util v1.
|
|
2
|
-
github.com/aperturerobotics/util v1.
|
|
3
|
-
github.com/aperturerobotics/util v1.14.3 h1:tn8eET9vlFwnveFY+rt4VbbMertQW8dcd+V5fK7SyHo=
|
|
4
|
-
github.com/aperturerobotics/util v1.14.3/go.mod h1:1+G2THhT7VCmR7xeRlqDnyEtRFvONWoPft19xTHvbyk=
|
|
1
|
+
github.com/aperturerobotics/util v1.16.0 h1:w0XOUw8pT+Dg/Q9eTXO9ZFALLIalV0AK7Ba8Nf8i1XU=
|
|
2
|
+
github.com/aperturerobotics/util v1.16.0/go.mod h1:aMfWWor4v05bs0dTekucKSjVkmnTxKE6UPs3rCe84YM=
|
|
5
3
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
6
4
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
7
5
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
@@ -17,12 +15,12 @@ github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuV
|
|
|
17
15
|
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
|
18
16
|
github.com/libp2p/go-buffer-pool v0.1.0 h1:oK4mSFcQz7cTQIfqbe4MIj9gLW+mnanjyFtc6cdF0Y8=
|
|
19
17
|
github.com/libp2p/go-buffer-pool v0.1.0/go.mod h1:N+vh8gMqimBzdKkSMVuydVDq+UV5QTWy5HSiZacSbPg=
|
|
20
|
-
github.com/libp2p/go-libp2p v0.33.
|
|
21
|
-
github.com/libp2p/go-libp2p v0.33.
|
|
18
|
+
github.com/libp2p/go-libp2p v0.33.2 h1:vCdwnFxoGOXMKmaGHlDSnL4bM3fQeW8pgIa9DECnb40=
|
|
19
|
+
github.com/libp2p/go-libp2p v0.33.2/go.mod h1:zTeppLuCvUIkT118pFVzA8xzP/p2dJYOMApCkFh0Yww=
|
|
22
20
|
github.com/libp2p/go-libp2p-testing v0.12.0 h1:EPvBb4kKMWO29qP4mZGyhVzUyR25dvfUIK5WDu6iPUA=
|
|
23
21
|
github.com/libp2p/go-libp2p-testing v0.12.0/go.mod h1:KcGDRXyN7sQCllucn1cOOS+Dmm7ujhfEyXQL5lvkcPg=
|
|
24
|
-
github.com/libp2p/go-yamux/v4 v4.0.2-0.
|
|
25
|
-
github.com/libp2p/go-yamux/v4 v4.0.2-0.
|
|
22
|
+
github.com/libp2p/go-yamux/v4 v4.0.2-0.20240322071716-53ef5820bd48 h1:KI65sCCL2h9IyCQwBhBXDgkKt3bmXoTu8T3rLVLZW4I=
|
|
23
|
+
github.com/libp2p/go-yamux/v4 v4.0.2-0.20240322071716-53ef5820bd48/go.mod h1:PGP+3py2ZWDKABvqstBZtMnixEHNC7U/odnGylzur5o=
|
|
26
24
|
github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM=
|
|
27
25
|
github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8=
|
|
28
26
|
github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o=
|
|
@@ -31,8 +29,8 @@ github.com/multiformats/go-base32 v0.1.0 h1:pVx9xoSPqEIQG8o+UbAe7DNi51oej1NtK+aG
|
|
|
31
29
|
github.com/multiformats/go-base32 v0.1.0/go.mod h1:Kj3tFY6zNr+ABYMqeUNeGvkIC/UYgtWibDcT0rExnbI=
|
|
32
30
|
github.com/multiformats/go-base36 v0.2.0 h1:lFsAbNOGeKtuKozrtBsAkSVhv1p9D0/qedU9rQyccr0=
|
|
33
31
|
github.com/multiformats/go-base36 v0.2.0/go.mod h1:qvnKE++v+2MWCfePClUEjE78Z7P2a1UV0xHgWc0hkp4=
|
|
34
|
-
github.com/multiformats/go-multiaddr v0.12.
|
|
35
|
-
github.com/multiformats/go-multiaddr v0.12.
|
|
32
|
+
github.com/multiformats/go-multiaddr v0.12.3 h1:hVBXvPRcKG0w80VinQ23P5t7czWgg65BmIvQKjDydU8=
|
|
33
|
+
github.com/multiformats/go-multiaddr v0.12.3/go.mod h1:sBXrNzucqkFJhvKOiwwLyqamGa/P5EIXNPLovyhQCII=
|
|
36
34
|
github.com/multiformats/go-multibase v0.2.0 h1:isdYCVLvksgWlMW9OZRYJEa9pZETFivncJHmHnnd87g=
|
|
37
35
|
github.com/multiformats/go-multibase v0.2.0/go.mod h1:bFBZX4lKCA/2lyOFSAoKH5SS6oPyjtnzK/XTFDPkNuk=
|
|
38
36
|
github.com/multiformats/go-multicodec v0.9.0 h1:pb/dlPnzee/Sxv/j4PmkDRxCOi3hXTz3IbPKOXWJkmg=
|
|
@@ -59,14 +57,14 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU
|
|
|
59
57
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
|
60
58
|
golang.org/x/crypto v0.19.0 h1:ENy+Az/9Y1vSrlrvBSyna3PITt4tiZLf7sgCjZBX7Wo=
|
|
61
59
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
|
62
|
-
golang.org/x/exp v0.0.0-
|
|
63
|
-
golang.org/x/exp v0.0.0-
|
|
60
|
+
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 h1:aAcj0Da7eBAtrTp03QXWvm88pSyOt+UgdZw2BFZ+lEw=
|
|
61
|
+
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8/go.mod h1:CQ1k9gNrJ50XIzaKCRR2hssIjF07kZFEiieALBM/ARQ=
|
|
64
62
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
65
63
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
66
|
-
golang.org/x/sys v0.
|
|
67
|
-
golang.org/x/sys v0.
|
|
68
|
-
google.golang.org/protobuf v1.
|
|
69
|
-
google.golang.org/protobuf v1.
|
|
64
|
+
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
|
65
|
+
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
|
66
|
+
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
|
67
|
+
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
|
70
68
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
71
69
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
72
70
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
@@ -3,6 +3,7 @@ package main
|
|
|
3
3
|
import (
|
|
4
4
|
"fmt"
|
|
5
5
|
"net/http"
|
|
6
|
+
"time"
|
|
6
7
|
|
|
7
8
|
"github.com/aperturerobotics/starpc/echo"
|
|
8
9
|
"github.com/aperturerobotics/starpc/srpc"
|
|
@@ -22,8 +23,13 @@ func main() {
|
|
|
22
23
|
logrus.Fatal(err.Error())
|
|
23
24
|
}
|
|
24
25
|
|
|
25
|
-
fmt.Print("listening on :5000\n")
|
|
26
|
-
|
|
26
|
+
fmt.Print("listening on localhost:5000\n")
|
|
27
|
+
hserver := &http.Server{
|
|
28
|
+
Addr: "localhost:5000",
|
|
29
|
+
Handler: server,
|
|
30
|
+
ReadHeaderTimeout: time.Second * 10,
|
|
31
|
+
}
|
|
32
|
+
if err := hserver.ListenAndServe(); err != nil {
|
|
27
33
|
logrus.Fatal(err.Error())
|
|
28
34
|
}
|
|
29
35
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starpc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -40,7 +40,9 @@
|
|
|
40
40
|
"deps": "depcheck --ignores 'bufferutil,utf-8-validate,ts-proto,rimraf,@aperturerobotics/ts-common'",
|
|
41
41
|
"codegen": "npm run gen",
|
|
42
42
|
"ci": "npm run build && npm run lint:js && npm run lint:go",
|
|
43
|
-
"format": "
|
|
43
|
+
"format": "npm run format:go && npm run format:js",
|
|
44
|
+
"format:go": "make format",
|
|
45
|
+
"format:js": "prettier --write './{srpc,echo,e2e,integration,rpcstream}/**/(*.ts|*.tsx|*.html|*.css)'",
|
|
44
46
|
"gen": "make genproto",
|
|
45
47
|
"test": "npm run test:js && npm run test:go",
|
|
46
48
|
"test:go": "make test",
|
package/srpc/channel.ts
CHANGED
|
@@ -89,7 +89,6 @@ export class ChannelStream<T = Uint8Array>
|
|
|
89
89
|
return this.remoteOpen ?? false
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
// remoteOpen indicates that we know the remote has already opened the stream.
|
|
93
92
|
constructor(localId: string, channel: ChannelPort, opts?: ChannelStreamOpts) {
|
|
94
93
|
// initial state
|
|
95
94
|
this.localId = localId
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//go:build js
|
|
2
|
+
|
|
3
|
+
package srpc
|
|
4
|
+
|
|
5
|
+
import (
|
|
6
|
+
"io"
|
|
7
|
+
"sync/atomic"
|
|
8
|
+
"syscall/js"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// PushablePacketWriter is a PacketWriter which writes packets to a Pushable<Uint8Array>.
|
|
12
|
+
type PushablePacketWriter struct {
|
|
13
|
+
closed atomic.Bool
|
|
14
|
+
pushable js.Value
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// NewPushablePacketWriter creates a new PushablePacketWriter.
|
|
18
|
+
func NewPushablePacketWriter(pushable js.Value) *PushablePacketWriter {
|
|
19
|
+
return &PushablePacketWriter{pushable: pushable}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// WritePacket writes a packet to the remote.
|
|
23
|
+
func (w *PushablePacketWriter) WritePacket(pkt *Packet) error {
|
|
24
|
+
if w.closed.Load() {
|
|
25
|
+
return io.ErrClosedPipe
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
data, err := pkt.MarshalVT()
|
|
29
|
+
if err != nil {
|
|
30
|
+
return err
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
a := js.Global().Get("Uint8Array").New(len(data))
|
|
34
|
+
js.CopyBytesToJS(a, data)
|
|
35
|
+
w.pushable.Call("push", a)
|
|
36
|
+
return nil
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Close closes the writer.
|
|
40
|
+
func (w *PushablePacketWriter) Close() error {
|
|
41
|
+
if !w.closed.Swap(true) {
|
|
42
|
+
w.pushable.Call("end")
|
|
43
|
+
}
|
|
44
|
+
return nil
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// _ is a type assertion
|
|
48
|
+
var _ PacketWriter = (*PushablePacketWriter)(nil)
|
package/srpc/rpcproto.pb.go
CHANGED
package/srpc/rpcproto.pb.ts
CHANGED
|
@@ -250,7 +250,7 @@ export const CallStart = {
|
|
|
250
250
|
if (message.data.length !== 0) {
|
|
251
251
|
writer.uint32(26).bytes(message.data)
|
|
252
252
|
}
|
|
253
|
-
if (message.dataIsZero
|
|
253
|
+
if (message.dataIsZero !== false) {
|
|
254
254
|
writer.uint32(32).bool(message.dataIsZero)
|
|
255
255
|
}
|
|
256
256
|
return writer
|
|
@@ -365,7 +365,7 @@ export const CallStart = {
|
|
|
365
365
|
if (message.data.length !== 0) {
|
|
366
366
|
obj.data = base64FromBytes(message.data)
|
|
367
367
|
}
|
|
368
|
-
if (message.dataIsZero
|
|
368
|
+
if (message.dataIsZero !== false) {
|
|
369
369
|
obj.dataIsZero = message.dataIsZero
|
|
370
370
|
}
|
|
371
371
|
return obj
|
|
@@ -403,10 +403,10 @@ export const CallData = {
|
|
|
403
403
|
if (message.data.length !== 0) {
|
|
404
404
|
writer.uint32(10).bytes(message.data)
|
|
405
405
|
}
|
|
406
|
-
if (message.dataIsZero
|
|
406
|
+
if (message.dataIsZero !== false) {
|
|
407
407
|
writer.uint32(16).bool(message.dataIsZero)
|
|
408
408
|
}
|
|
409
|
-
if (message.complete
|
|
409
|
+
if (message.complete !== false) {
|
|
410
410
|
writer.uint32(24).bool(message.complete)
|
|
411
411
|
}
|
|
412
412
|
if (message.error !== '') {
|
|
@@ -516,10 +516,10 @@ export const CallData = {
|
|
|
516
516
|
if (message.data.length !== 0) {
|
|
517
517
|
obj.data = base64FromBytes(message.data)
|
|
518
518
|
}
|
|
519
|
-
if (message.dataIsZero
|
|
519
|
+
if (message.dataIsZero !== false) {
|
|
520
520
|
obj.dataIsZero = message.dataIsZero
|
|
521
521
|
}
|
|
522
|
-
if (message.complete
|
|
522
|
+
if (message.complete !== false) {
|
|
523
523
|
obj.complete = message.complete
|
|
524
524
|
}
|
|
525
525
|
if (message.error !== '') {
|