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.
Files changed (86) hide show
  1. package/README.md +1 -3
  2. package/cmd/protoc-gen-es-starpc/typescript.ts +11 -6
  3. package/dist/cmd/protoc-gen-es-starpc/typescript.js +6 -5
  4. package/dist/echo/echo.pb.d.ts +1 -1
  5. package/dist/echo/echo.pb.js +3 -3
  6. package/dist/integration/cross-language/ts-client.js +84 -11
  7. package/dist/integration/cross-language/ts-server.js +100 -4
  8. package/dist/mock/index.d.ts +2 -2
  9. package/dist/mock/index.js +2 -2
  10. package/dist/mock/mock.pb.d.ts +1 -1
  11. package/dist/mock/mock.pb.js +3 -3
  12. package/dist/rpcstream/receipt.test.d.ts +1 -0
  13. package/dist/rpcstream/receipt.test.js +41 -0
  14. package/dist/rpcstream/rpcstream.pb.d.ts +1 -1
  15. package/dist/rpcstream/rpcstream.pb.js +14 -8
  16. package/dist/srpc/call-receipt.d.ts +17 -0
  17. package/dist/srpc/call-receipt.js +106 -0
  18. package/dist/srpc/call-receipt.test.d.ts +1 -0
  19. package/dist/srpc/call-receipt.test.js +375 -0
  20. package/dist/srpc/client.d.ts +3 -1
  21. package/dist/srpc/client.js +20 -0
  22. package/dist/srpc/common-rpc.d.ts +13 -3
  23. package/dist/srpc/common-rpc.js +87 -10
  24. package/dist/srpc/handler.d.ts +2 -1
  25. package/dist/srpc/index.d.ts +4 -0
  26. package/dist/srpc/index.js +3 -0
  27. package/dist/srpc/invoker.d.ts +2 -1
  28. package/dist/srpc/invoker.js +2 -2
  29. package/dist/srpc/rpcproto.pb.d.ts +45 -1
  30. package/dist/srpc/rpcproto.pb.js +60 -7
  31. package/dist/srpc/server-invocation.d.ts +17 -0
  32. package/dist/srpc/server-invocation.js +37 -0
  33. package/dist/srpc/server-rpc.js +3 -1
  34. package/echo/echo.pb.go +1 -1
  35. package/echo/echo.pb.ts +6 -5
  36. package/echo/echo_srpc.pb.cpp +1 -1
  37. package/echo/echo_srpc.pb.go +1 -1
  38. package/echo/echo_srpc.pb.hpp +1 -1
  39. package/echo/echo_srpc.pb.rs +1 -1
  40. package/go.mod +13 -12
  41. package/go.sum +24 -24
  42. package/integration/cross-language/go-client/main.go +137 -5
  43. package/integration/cross-language/go-server/fixture-owner_test.go +127 -0
  44. package/integration/cross-language/go-server/main.go +169 -4
  45. package/integration/cross-language/run.bash +117 -13
  46. package/integration/cross-language/ts-client.ts +94 -13
  47. package/integration/cross-language/ts-server.ts +115 -7
  48. package/mock/index.ts +2 -2
  49. package/mock/mock.pb.go +1 -1
  50. package/mock/mock.pb.ts +6 -5
  51. package/mock/mock_srpc.pb.cpp +1 -1
  52. package/mock/mock_srpc.pb.go +1 -1
  53. package/mock/mock_srpc.pb.hpp +1 -1
  54. package/mock/mock_srpc.pb.rs +1 -1
  55. package/package.json +19 -26
  56. package/srpc/accept.go +1 -1
  57. package/srpc/call-receipt-e2e_test.go +111 -0
  58. package/srpc/call-receipt.go +112 -0
  59. package/srpc/call-receipt.test.ts +441 -0
  60. package/srpc/call-receipt.ts +131 -0
  61. package/srpc/call-receipt_test.go +536 -0
  62. package/srpc/client-rpc.go +1 -8
  63. package/srpc/client.ts +29 -2
  64. package/srpc/common-rpc.go +114 -29
  65. package/srpc/common-rpc.ts +104 -13
  66. package/srpc/handler.ts +2 -0
  67. package/srpc/index.ts +4 -0
  68. package/srpc/invoker.ts +10 -5
  69. package/srpc/msg-stream.go +8 -0
  70. package/srpc/muxed-conn.go +9 -4
  71. package/srpc/muxed-conn_test.go +79 -0
  72. package/srpc/muxed-yamux.go +1 -1
  73. package/srpc/rpcproto.pb.cc +15 -4
  74. package/srpc/rpcproto.pb.go +97 -1
  75. package/srpc/rpcproto.pb.h +59 -0
  76. package/srpc/rpcproto.pb.rs +45 -0
  77. package/srpc/rpcproto.pb.ts +90 -27
  78. package/srpc/rpcproto.proto +16 -0
  79. package/srpc/schema-ownership_test.go +115 -0
  80. package/srpc/server-invocation.go +40 -0
  81. package/srpc/server-invocation.ts +76 -0
  82. package/srpc/server-rpc.go +1 -1
  83. package/srpc/server-rpc.ts +6 -2
  84. package/srpc/stream-yamux.go +1 -1
  85. package/srpc/stream.go +20 -0
  86. package/srpc/websocket.go +1 -1
@@ -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
  }
@@ -4,7 +4,7 @@ import (
4
4
  "errors"
5
5
  "time"
6
6
 
7
- yamux "github.com/libp2p/go-yamux/v4"
7
+ yamux "github.com/libp2p/go-yamux/v5"
8
8
  )
9
9
 
10
10
  // yamuxStream wraps a yamux.Stream to implement MuxedStream.
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)
package/srpc/websocket.go CHANGED
@@ -4,7 +4,7 @@ import (
4
4
  "context"
5
5
 
6
6
  "github.com/aperturerobotics/go-websocket"
7
- "github.com/libp2p/go-yamux/v4"
7
+ "github.com/libp2p/go-yamux/v5"
8
8
  )
9
9
 
10
10
  // NewWebSocketConn wraps a websocket into a MuxedConn.