starpc 0.22.0 → 0.22.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/README.md +0 -1
- package/dist/srpc/common-rpc.d.ts +1 -0
- package/dist/srpc/common-rpc.js +6 -6
- package/dist/srpc/index.d.ts +3 -1
- package/dist/srpc/index.js +2 -0
- package/go.mod +2 -2
- package/go.sum +4 -8
- package/package.json +2 -2
- package/srpc/common-rpc.ts +9 -8
- package/srpc/index.ts +3 -1
package/README.md
CHANGED
|
@@ -9,6 +9,7 @@ export declare class CommonRPC {
|
|
|
9
9
|
private readonly _rpcDataSource;
|
|
10
10
|
protected service?: string;
|
|
11
11
|
protected method?: string;
|
|
12
|
+
private closed?;
|
|
12
13
|
constructor();
|
|
13
14
|
writeCallData(data?: Uint8Array, complete?: boolean, error?: string): Promise<void>;
|
|
14
15
|
writeCallCancel(): Promise<void>;
|
package/dist/srpc/common-rpc.js
CHANGED
|
@@ -116,6 +116,10 @@ export class CommonRPC {
|
|
|
116
116
|
}
|
|
117
117
|
// close closes the call, optionally with an error.
|
|
118
118
|
async close(err) {
|
|
119
|
+
if (this.closed) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
this.closed = true;
|
|
119
123
|
try {
|
|
120
124
|
await this.writeCallCancel();
|
|
121
125
|
}
|
|
@@ -141,15 +145,11 @@ export class CommonRPC {
|
|
|
141
145
|
await this.handlePacket(msg);
|
|
142
146
|
}
|
|
143
147
|
}
|
|
148
|
+
this._rpcDataSource.end();
|
|
144
149
|
}
|
|
145
150
|
catch (err) {
|
|
146
|
-
|
|
147
|
-
if (anyErr?.code !== 'ERR_STREAM_RESET' &&
|
|
148
|
-
anyErr?.code !== 'ERR_STREAM_ABORT') {
|
|
149
|
-
this.close(err);
|
|
150
|
-
}
|
|
151
|
+
this.close(err);
|
|
151
152
|
}
|
|
152
|
-
this._rpcDataSource.end();
|
|
153
153
|
};
|
|
154
154
|
}
|
|
155
155
|
}
|
package/dist/srpc/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export type { PacketHandler, Stream, OpenStreamFunc } from './stream.js';
|
|
2
1
|
export { ERR_RPC_ABORT, isAbortError, castToError } from './errors.js';
|
|
3
2
|
export { Client } from './client.js';
|
|
4
3
|
export { Server } from './server.js';
|
|
5
4
|
export { Conn, ConnParams } from './conn.js';
|
|
5
|
+
export { WebSocketConn } from './websocket.js';
|
|
6
|
+
export { StreamConn } from './conn-stream.js';
|
|
7
|
+
export type { PacketHandler, Stream, OpenStreamFunc } from './stream.js';
|
|
6
8
|
export { Handler, InvokeFn, createHandler, createInvokeFn } from './handler.js';
|
|
7
9
|
export { Packet, CallStart, CallData } from './rpcproto.pb.js';
|
|
8
10
|
export { Mux, StaticMux, createMux } from './mux.js';
|
package/dist/srpc/index.js
CHANGED
|
@@ -2,6 +2,8 @@ export { ERR_RPC_ABORT, isAbortError, castToError } from './errors.js';
|
|
|
2
2
|
export { Client } from './client.js';
|
|
3
3
|
export { Server } from './server.js';
|
|
4
4
|
export { Conn } from './conn.js';
|
|
5
|
+
export { WebSocketConn } from './websocket.js';
|
|
6
|
+
export { StreamConn } from './conn-stream.js';
|
|
5
7
|
export { createHandler, createInvokeFn } from './handler.js';
|
|
6
8
|
export { Packet, CallStart, CallData } from './rpcproto.pb.js';
|
|
7
9
|
export { StaticMux, createMux } from './mux.js';
|
package/go.mod
CHANGED
|
@@ -4,12 +4,12 @@ go 1.19
|
|
|
4
4
|
|
|
5
5
|
require (
|
|
6
6
|
github.com/pkg/errors v0.9.1 // latest
|
|
7
|
-
google.golang.org/protobuf v1.
|
|
7
|
+
google.golang.org/protobuf v1.32.0 // latest
|
|
8
8
|
nhooyr.io/websocket v1.8.10 // master
|
|
9
9
|
)
|
|
10
10
|
|
|
11
11
|
require (
|
|
12
|
-
github.com/aperturerobotics/util v1.8.
|
|
12
|
+
github.com/aperturerobotics/util v1.8.3 // latest
|
|
13
13
|
github.com/libp2p/go-libp2p v0.32.2 // latest
|
|
14
14
|
github.com/libp2p/go-yamux/v4 v4.0.1 // master
|
|
15
15
|
github.com/sirupsen/logrus v1.9.3 // latest
|
package/go.sum
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
github.com/aperturerobotics/util v1.8.
|
|
2
|
-
github.com/aperturerobotics/util v1.8.
|
|
1
|
+
github.com/aperturerobotics/util v1.8.3 h1:P+nU185SJKSzXXYTc1kdnzt6KNvxgV1ke0jbxltfwaI=
|
|
2
|
+
github.com/aperturerobotics/util v1.8.3/go.mod h1:idhGuFuAatygqticAnPcSZhef8yV7TYufLUw1Qfj4Cg=
|
|
3
3
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
4
4
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
5
5
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
6
6
|
github.com/decred/dcrd/crypto/blake256 v1.0.1 h1:7PltbUIQB7u/FfZ39+DGa/ShuMyJ5ilcvdfma9wOH6Y=
|
|
7
7
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 h1:8UrgZ3GkP4i/CLijOJx79Yu+etlyjdBU4sfcs2WYQMs=
|
|
8
8
|
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0/go.mod h1:v57UDF4pDQJcEfFUCRop3lJL149eHGSe9Jvczhzjo/0=
|
|
9
|
-
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
|
10
|
-
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
|
11
9
|
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
|
|
12
10
|
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
|
|
13
11
|
github.com/ipfs/go-cid v0.4.1/go.mod h1:uQHwDeX4c6CtyrFwdqyhpNcxVewur1M7l7fNU7LKwZk=
|
|
@@ -59,10 +57,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
|
|
|
59
57
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
60
58
|
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
|
61
59
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
62
|
-
golang.org/
|
|
63
|
-
google.golang.org/protobuf v1.
|
|
64
|
-
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
|
|
65
|
-
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
|
60
|
+
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
|
|
61
|
+
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
|
66
62
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
67
63
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
68
64
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starpc",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.2",
|
|
4
4
|
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"singleQuote": true
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@aperturerobotics/ts-common": "^0.
|
|
64
|
+
"@aperturerobotics/ts-common": "^0.8.0",
|
|
65
65
|
"@typescript-eslint/eslint-plugin": "^6.15.0",
|
|
66
66
|
"@typescript-eslint/parser": "^6.15.0",
|
|
67
67
|
"bufferutil": "^4.0.7",
|
package/srpc/common-rpc.ts
CHANGED
|
@@ -28,6 +28,9 @@ export class CommonRPC {
|
|
|
28
28
|
// method is the rpc method
|
|
29
29
|
protected method?: string
|
|
30
30
|
|
|
31
|
+
// closed indicates this rpc has been closed already.
|
|
32
|
+
private closed?: boolean
|
|
33
|
+
|
|
31
34
|
constructor() {
|
|
32
35
|
this.sink = this._createSink()
|
|
33
36
|
this.source = this._source
|
|
@@ -150,6 +153,10 @@ export class CommonRPC {
|
|
|
150
153
|
|
|
151
154
|
// close closes the call, optionally with an error.
|
|
152
155
|
public async close(err?: Error) {
|
|
156
|
+
if (this.closed) {
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
this.closed = true
|
|
153
160
|
try {
|
|
154
161
|
await this.writeCallCancel()
|
|
155
162
|
} finally {
|
|
@@ -174,16 +181,10 @@ export class CommonRPC {
|
|
|
174
181
|
await this.handlePacket(msg)
|
|
175
182
|
}
|
|
176
183
|
}
|
|
184
|
+
this._rpcDataSource.end()
|
|
177
185
|
} catch (err) {
|
|
178
|
-
|
|
179
|
-
if (
|
|
180
|
-
anyErr?.code !== 'ERR_STREAM_RESET' &&
|
|
181
|
-
anyErr?.code !== 'ERR_STREAM_ABORT'
|
|
182
|
-
) {
|
|
183
|
-
this.close(err as Error)
|
|
184
|
-
}
|
|
186
|
+
this.close(err as Error)
|
|
185
187
|
}
|
|
186
|
-
this._rpcDataSource.end()
|
|
187
188
|
}
|
|
188
189
|
}
|
|
189
190
|
}
|
package/srpc/index.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
export type { PacketHandler, Stream, OpenStreamFunc } from './stream.js'
|
|
2
1
|
export { ERR_RPC_ABORT, isAbortError, castToError } from './errors.js'
|
|
3
2
|
export { Client } from './client.js'
|
|
4
3
|
export { Server } from './server.js'
|
|
5
4
|
export { Conn, ConnParams } from './conn.js'
|
|
5
|
+
export { WebSocketConn } from './websocket.js'
|
|
6
|
+
export { StreamConn } from './conn-stream.js'
|
|
7
|
+
export type { PacketHandler, Stream, OpenStreamFunc } from './stream.js'
|
|
6
8
|
export { Handler, InvokeFn, createHandler, createInvokeFn } from './handler.js'
|
|
7
9
|
export { Packet, CallStart, CallData } from './rpcproto.pb.js'
|
|
8
10
|
export { Mux, StaticMux, createMux } from './mux.js'
|