starpc 0.49.18 → 0.50.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/README.md +1 -3
- package/cmd/protoc-gen-es-starpc/typescript.ts +11 -6
- package/dist/cmd/protoc-gen-es-starpc/typescript.js +6 -5
- package/dist/echo/echo.pb.d.ts +1 -1
- package/dist/echo/echo.pb.js +3 -3
- package/dist/integration/cross-language/ts-client.js +84 -11
- package/dist/integration/cross-language/ts-server.js +100 -4
- package/dist/mock/index.d.ts +2 -2
- package/dist/mock/index.js +2 -2
- package/dist/mock/mock.pb.d.ts +1 -1
- package/dist/mock/mock.pb.js +3 -3
- package/dist/rpcstream/receipt.test.d.ts +1 -0
- package/dist/rpcstream/receipt.test.js +41 -0
- package/dist/rpcstream/rpcstream.pb.d.ts +1 -1
- package/dist/rpcstream/rpcstream.pb.js +14 -8
- package/dist/srpc/call-receipt.d.ts +17 -0
- package/dist/srpc/call-receipt.js +106 -0
- package/dist/srpc/call-receipt.test.d.ts +1 -0
- package/dist/srpc/call-receipt.test.js +375 -0
- package/dist/srpc/client.d.ts +3 -1
- package/dist/srpc/client.js +20 -0
- package/dist/srpc/common-rpc.d.ts +13 -3
- package/dist/srpc/common-rpc.js +87 -10
- package/dist/srpc/handler.d.ts +2 -1
- package/dist/srpc/index.d.ts +4 -0
- package/dist/srpc/index.js +3 -0
- package/dist/srpc/invoker.d.ts +2 -1
- package/dist/srpc/invoker.js +2 -2
- package/dist/srpc/rpcproto.pb.d.ts +45 -1
- package/dist/srpc/rpcproto.pb.js +60 -7
- package/dist/srpc/server-invocation.d.ts +17 -0
- package/dist/srpc/server-invocation.js +37 -0
- package/dist/srpc/server-rpc.js +3 -1
- package/echo/echo.pb.go +1 -1
- package/echo/echo.pb.ts +6 -5
- package/echo/echo_srpc.pb.cpp +1 -1
- package/echo/echo_srpc.pb.go +1 -1
- package/echo/echo_srpc.pb.hpp +1 -1
- package/echo/echo_srpc.pb.rs +1 -1
- package/go.mod +13 -12
- package/go.sum +24 -24
- package/integration/cross-language/go-client/main.go +137 -5
- package/integration/cross-language/go-server/fixture-owner_test.go +127 -0
- package/integration/cross-language/go-server/main.go +169 -4
- package/integration/cross-language/run.bash +117 -13
- package/integration/cross-language/ts-client.ts +94 -13
- package/integration/cross-language/ts-server.ts +115 -7
- package/mock/index.ts +2 -2
- package/mock/mock.pb.go +1 -1
- package/mock/mock.pb.ts +6 -5
- package/mock/mock_srpc.pb.cpp +1 -1
- package/mock/mock_srpc.pb.go +1 -1
- package/mock/mock_srpc.pb.hpp +1 -1
- package/mock/mock_srpc.pb.rs +1 -1
- package/package.json +19 -26
- package/srpc/accept.go +1 -1
- package/srpc/call-receipt-e2e_test.go +111 -0
- package/srpc/call-receipt.go +112 -0
- package/srpc/call-receipt.test.ts +441 -0
- package/srpc/call-receipt.ts +131 -0
- package/srpc/call-receipt_test.go +536 -0
- package/srpc/client-rpc.go +1 -8
- package/srpc/client.ts +29 -2
- package/srpc/common-rpc.go +114 -29
- package/srpc/common-rpc.ts +104 -13
- package/srpc/handler.ts +2 -0
- package/srpc/index.ts +4 -0
- package/srpc/invoker.ts +10 -5
- package/srpc/msg-stream.go +8 -0
- package/srpc/muxed-conn.go +9 -4
- package/srpc/muxed-conn_test.go +79 -0
- package/srpc/muxed-yamux.go +1 -1
- package/srpc/rpcproto.pb.cc +15 -4
- package/srpc/rpcproto.pb.go +97 -1
- package/srpc/rpcproto.pb.h +59 -0
- package/srpc/rpcproto.pb.rs +45 -0
- package/srpc/rpcproto.pb.ts +90 -27
- package/srpc/rpcproto.proto +16 -0
- package/srpc/schema-ownership_test.go +115 -0
- package/srpc/server-invocation.go +40 -0
- package/srpc/server-invocation.ts +76 -0
- package/srpc/server-rpc.go +1 -1
- package/srpc/server-rpc.ts +6 -2
- package/srpc/stream-yamux.go +1 -1
- package/srpc/stream.go +20 -0
- package/srpc/websocket.go +1 -1
package/srpc/server-rpc.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { Sink, Source } from 'it-stream-types'
|
|
|
3
3
|
import type { CallData, CallStart } from './rpcproto.pb.js'
|
|
4
4
|
import { CommonRPC } from './common-rpc.js'
|
|
5
5
|
import { InvokeFn } from './handler.js'
|
|
6
|
+
import { ServerInvocation } from './server-invocation.js'
|
|
6
7
|
import { LookupMethod } from './mux.js'
|
|
7
8
|
|
|
8
9
|
// ServerRPC is an ongoing RPC from the server side.
|
|
@@ -43,12 +44,15 @@ export class ServerRPC extends CommonRPC {
|
|
|
43
44
|
}
|
|
44
45
|
return super.handleCallData(packet)
|
|
45
46
|
}
|
|
46
|
-
|
|
47
47
|
// invokeRPC starts invoking the RPC handler.
|
|
48
48
|
private async invokeRPC(invokeFn: InvokeFn) {
|
|
49
49
|
const dataSink = this._createDataSink()
|
|
50
|
+
const invocation = new ServerInvocation(
|
|
51
|
+
this.invocationSignal,
|
|
52
|
+
(ownerSignal) => this.waitTerminal(ownerSignal),
|
|
53
|
+
)
|
|
50
54
|
try {
|
|
51
|
-
await invokeFn(this.rpcDataSource, dataSink)
|
|
55
|
+
await invokeFn(this.rpcDataSource, dataSink, invocation)
|
|
52
56
|
} catch (err) {
|
|
53
57
|
this.close(err as Error)
|
|
54
58
|
}
|
package/srpc/stream-yamux.go
CHANGED
package/srpc/stream.go
CHANGED
|
@@ -23,6 +23,10 @@ type Stream interface {
|
|
|
23
23
|
Close() error
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
type receiptTerminalStream interface {
|
|
27
|
+
receiptTerminalKind() (TerminalKind, bool)
|
|
28
|
+
}
|
|
29
|
+
|
|
26
30
|
// StreamRecv is a stream that can receive typed messages.
|
|
27
31
|
//
|
|
28
32
|
// T is the response type.
|
|
@@ -69,6 +73,14 @@ func (s *streamWithClose) Close() error {
|
|
|
69
73
|
return err2
|
|
70
74
|
}
|
|
71
75
|
|
|
76
|
+
func (s *streamWithClose) receiptTerminalKind() (TerminalKind, bool) {
|
|
77
|
+
receipt, ok := s.Stream.(receiptTerminalStream)
|
|
78
|
+
if !ok {
|
|
79
|
+
return 0, false
|
|
80
|
+
}
|
|
81
|
+
return receipt.receiptTerminalKind()
|
|
82
|
+
}
|
|
83
|
+
|
|
72
84
|
// streamWithContext is a Stream with a wrapped Context function.
|
|
73
85
|
type streamWithContext struct {
|
|
74
86
|
Stream
|
|
@@ -85,6 +97,14 @@ func (s *streamWithContext) Context() context.Context {
|
|
|
85
97
|
return s.ctx
|
|
86
98
|
}
|
|
87
99
|
|
|
100
|
+
func (s *streamWithContext) receiptTerminalKind() (TerminalKind, bool) {
|
|
101
|
+
receipt, ok := s.Stream.(receiptTerminalStream)
|
|
102
|
+
if !ok {
|
|
103
|
+
return 0, false
|
|
104
|
+
}
|
|
105
|
+
return receipt.receiptTerminalKind()
|
|
106
|
+
}
|
|
107
|
+
|
|
88
108
|
// _ is a type assertion
|
|
89
109
|
var (
|
|
90
110
|
_ Stream = (*streamWithClose)(nil)
|