starpc 0.4.9 → 0.5.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 (64) hide show
  1. package/Makefile +1 -0
  2. package/README.md +20 -10
  3. package/dist/echo/client-test.d.ts +1 -0
  4. package/dist/echo/client-test.js +20 -18
  5. package/dist/echo/echo.pb.d.ts +165 -12
  6. package/dist/echo/echo.pb.js +61 -17
  7. package/dist/echo/server.d.ts +8 -4
  8. package/dist/echo/server.js +29 -37
  9. package/dist/rpcstream/rpcstream.d.ts +6 -6
  10. package/dist/rpcstream/rpcstream.js +92 -51
  11. package/dist/rpcstream/rpcstream.pb.d.ts +46 -1
  12. package/dist/rpcstream/rpcstream.pb.js +157 -9
  13. package/dist/srpc/client.d.ts +3 -4
  14. package/dist/srpc/client.js +12 -46
  15. package/dist/srpc/common-rpc.d.ts +3 -2
  16. package/dist/srpc/common-rpc.js +12 -0
  17. package/dist/srpc/definition.d.ts +3 -3
  18. package/dist/srpc/handler.d.ts +2 -3
  19. package/dist/srpc/handler.js +5 -22
  20. package/dist/srpc/index.d.ts +1 -1
  21. package/dist/srpc/index.js +1 -1
  22. package/dist/srpc/packet.js +0 -32
  23. package/dist/srpc/pushable.d.ts +2 -0
  24. package/dist/srpc/pushable.js +13 -0
  25. package/dist/srpc/rpcproto.pb.d.ts +13 -6
  26. package/dist/srpc/rpcproto.pb.js +95 -10
  27. package/dist/srpc/server.d.ts +1 -0
  28. package/dist/srpc/server.js +7 -0
  29. package/dist/srpc/ts-proto-rpc.d.ts +3 -4
  30. package/e2e/e2e.ts +4 -3
  31. package/e2e/e2e_test.go +24 -1
  32. package/echo/client-test.ts +23 -18
  33. package/echo/echo.pb.go +33 -20
  34. package/echo/echo.pb.ts +90 -34
  35. package/echo/echo.proto +4 -0
  36. package/echo/echo_srpc.pb.go +77 -0
  37. package/echo/server.go +18 -0
  38. package/echo/server.ts +47 -41
  39. package/integration/integration.go +1 -2
  40. package/integration/integration.ts +5 -1
  41. package/integration/integration_srpc.pb.go +139 -0
  42. package/package.json +5 -3
  43. package/patches/ts-proto+1.115.5.patch +1339 -0
  44. package/srpc/client.ts +16 -50
  45. package/srpc/common-rpc.ts +14 -2
  46. package/srpc/definition.ts +3 -3
  47. package/srpc/handler.ts +17 -34
  48. package/srpc/index.ts +1 -1
  49. package/srpc/muxed-conn.go +2 -2
  50. package/srpc/packet-rw.go +4 -6
  51. package/srpc/packet.ts +0 -33
  52. package/srpc/pushable.ts +17 -0
  53. package/srpc/rpcproto.pb.ts +122 -12
  54. package/srpc/server-pipe.go +2 -2
  55. package/srpc/server.go +2 -2
  56. package/srpc/server.ts +8 -0
  57. package/srpc/ts-proto-rpc.ts +4 -6
  58. package/srpc/websocket.go +2 -2
  59. package/dist/echo/sever.d.ts +0 -0
  60. package/dist/echo/sever.js +0 -1
  61. package/dist/srpc/observable-source.d.ts +0 -9
  62. package/dist/srpc/observable-source.js +0 -25
  63. package/echo/sever.ts +0 -0
  64. package/srpc/observable-source.ts +0 -40
@@ -0,0 +1,139 @@
1
+ // Code generated by protoc-gen-srpc. DO NOT EDIT.
2
+ // protoc-gen-srpc version: v0.0.0-20220611014014-aa9dc5523865
3
+ // source: github.com/aperturerobotics/starpc/integration/integration.proto
4
+
5
+ package main
6
+
7
+ import (
8
+ context "context"
9
+
10
+ rpcstream "github.com/aperturerobotics/starpc/rpcstream"
11
+ srpc "github.com/aperturerobotics/starpc/srpc"
12
+ )
13
+
14
+ type SRPCIntegrationServiceClient interface {
15
+ SRPCClient() srpc.Client
16
+
17
+ RpcStream(ctx context.Context) (SRPCIntegrationService_RpcStreamClient, error)
18
+ }
19
+
20
+ type srpcIntegrationServiceClient struct {
21
+ cc srpc.Client
22
+ }
23
+
24
+ func NewSRPCIntegrationServiceClient(cc srpc.Client) SRPCIntegrationServiceClient {
25
+ return &srpcIntegrationServiceClient{cc}
26
+ }
27
+
28
+ func (c *srpcIntegrationServiceClient) SRPCClient() srpc.Client { return c.cc }
29
+
30
+ func (c *srpcIntegrationServiceClient) RpcStream(ctx context.Context) (SRPCIntegrationService_RpcStreamClient, error) {
31
+ stream, err := c.cc.NewStream(ctx, "main.IntegrationService", "RpcStream", nil)
32
+ if err != nil {
33
+ return nil, err
34
+ }
35
+ strm := &srpcIntegrationService_RpcStreamClient{stream}
36
+ return strm, nil
37
+ }
38
+
39
+ type SRPCIntegrationService_RpcStreamClient interface {
40
+ srpc.Stream
41
+ Send(*rpcstream.RpcStreamPacket) error
42
+ Recv() (*rpcstream.RpcStreamPacket, error)
43
+ RecvTo(*rpcstream.RpcStreamPacket) error
44
+ }
45
+
46
+ type srpcIntegrationService_RpcStreamClient struct {
47
+ srpc.Stream
48
+ }
49
+
50
+ func (x *srpcIntegrationService_RpcStreamClient) Send(m *rpcstream.RpcStreamPacket) error {
51
+ return x.MsgSend(m)
52
+ }
53
+
54
+ func (x *srpcIntegrationService_RpcStreamClient) Recv() (*rpcstream.RpcStreamPacket, error) {
55
+ m := new(rpcstream.RpcStreamPacket)
56
+ if err := x.MsgRecv(m); err != nil {
57
+ return nil, err
58
+ }
59
+ return m, nil
60
+ }
61
+
62
+ func (x *srpcIntegrationService_RpcStreamClient) RecvTo(m *rpcstream.RpcStreamPacket) error {
63
+ return x.MsgRecv(m)
64
+ }
65
+
66
+ type SRPCIntegrationServiceServer interface {
67
+ RpcStream(SRPCIntegrationService_RpcStreamStream) error
68
+ }
69
+
70
+ type SRPCIntegrationServiceUnimplementedServer struct{}
71
+
72
+ func (s *SRPCIntegrationServiceUnimplementedServer) RpcStream(SRPCIntegrationService_RpcStreamStream) error {
73
+ return srpc.ErrUnimplemented
74
+ }
75
+
76
+ const SRPCIntegrationServiceServiceID = "main.IntegrationService"
77
+
78
+ type SRPCIntegrationServiceHandler struct {
79
+ impl SRPCIntegrationServiceServer
80
+ }
81
+
82
+ func (SRPCIntegrationServiceHandler) GetServiceID() string { return SRPCIntegrationServiceServiceID }
83
+
84
+ func (SRPCIntegrationServiceHandler) GetMethodIDs() []string {
85
+ return []string{
86
+ "RpcStream",
87
+ }
88
+ }
89
+
90
+ func (d *SRPCIntegrationServiceHandler) InvokeMethod(
91
+ serviceID, methodID string,
92
+ strm srpc.Stream,
93
+ ) (bool, error) {
94
+ if serviceID != "" && serviceID != d.GetServiceID() {
95
+ return false, nil
96
+ }
97
+
98
+ switch methodID {
99
+ case "RpcStream":
100
+ return true, d.InvokeMethod_RpcStream(d.impl, strm)
101
+ default:
102
+ return false, nil
103
+ }
104
+ }
105
+
106
+ func (SRPCIntegrationServiceHandler) InvokeMethod_RpcStream(impl SRPCIntegrationServiceServer, strm srpc.Stream) error {
107
+ clientStrm := &srpcIntegrationService_RpcStreamStream{strm}
108
+ return impl.RpcStream(clientStrm)
109
+ }
110
+
111
+ func SRPCRegisterIntegrationService(mux srpc.Mux, impl SRPCIntegrationServiceServer) error {
112
+ return mux.Register(&SRPCIntegrationServiceHandler{impl: impl})
113
+ }
114
+
115
+ type SRPCIntegrationService_RpcStreamStream interface {
116
+ srpc.Stream
117
+ Send(*rpcstream.RpcStreamPacket) error
118
+ Recv() (*rpcstream.RpcStreamPacket, error)
119
+ }
120
+
121
+ type srpcIntegrationService_RpcStreamStream struct {
122
+ srpc.Stream
123
+ }
124
+
125
+ func (x *srpcIntegrationService_RpcStreamStream) Send(m *rpcstream.RpcStreamPacket) error {
126
+ return x.MsgSend(m)
127
+ }
128
+
129
+ func (x *srpcIntegrationService_RpcStreamStream) Recv() (*rpcstream.RpcStreamPacket, error) {
130
+ m := new(rpcstream.RpcStreamPacket)
131
+ if err := x.MsgRecv(m); err != nil {
132
+ return nil, err
133
+ }
134
+ return m, nil
135
+ }
136
+
137
+ func (x *srpcIntegrationService_RpcStreamStream) RecvTo(m *rpcstream.RpcStreamPacket) error {
138
+ return x.MsgRecv(m)
139
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starpc",
3
- "version": "0.4.9",
3
+ "version": "0.5.0",
4
4
  "description": "Streaming protobuf RPC service protocol over any two-way channel.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -42,7 +42,9 @@
42
42
  "gen": "make genproto",
43
43
  "test": "npm run test:js && npm run test:go",
44
44
  "test:go": "make test",
45
- "test:js": "npm run build && cd e2e && esbuild e2e.ts --sourcemap --outfile=e2e.js --bundle --platform=node && node ./e2e.js",
45
+ "build:e2e": "npm run build && cd e2e && esbuild e2e.ts --sourcemap --outfile=e2e.js --bundle --platform=node",
46
+ "test:js": "npm run build:e2e && cd e2e && node ./e2e.js",
47
+ "debug:js": "npm run build:e2e && cd e2e && node --inspect --inspect-brk ./e2e.js",
46
48
  "test:integration": "make integration",
47
49
  "integration": "npm run test:integration",
48
50
  "lint": "npm run lint:go && npm run lint:js",
@@ -73,6 +75,7 @@
73
75
  "@libp2p/mplex": "^4.0.0",
74
76
  "event-iterator": "^2.0.0",
75
77
  "isomorphic-ws": "^5.0.0",
78
+ "it-first": "^1.0.7",
76
79
  "it-length-prefixed": "^7.0.1",
77
80
  "it-pipe": "^2.0.3",
78
81
  "it-pushable": "^3.0.0",
@@ -81,7 +84,6 @@
81
84
  "long": "^5.2.0",
82
85
  "patch-package": "^6.4.7",
83
86
  "protobufjs": "^6.11.3",
84
- "rxjs": "^7.5.5",
85
87
  "ws": "^8.8.0"
86
88
  }
87
89
  }