starpc 0.0.1
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 +56 -0
- package/package.json +15 -0
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# Stream RPC (starpc)
|
|
2
|
+
|
|
3
|
+
**starpc** is a Protobuf RPC implementation leveraging an external Stream
|
|
4
|
+
multiplexer and Message framing system like HTTP/2 or Yamux.
|
|
5
|
+
|
|
6
|
+
Uses any two-way ordered message channel like WebSocket or BroadcastChannel.
|
|
7
|
+
|
|
8
|
+
Implementation features:
|
|
9
|
+
|
|
10
|
+
- Generates a Go server for proto3 services that does not use reflection.
|
|
11
|
+
- Uses the **ts-proto** RPC interface to implement TypeScript clients.
|
|
12
|
+
- Each RPC call is mapped to a Stream preventing head-of-line blocking.
|
|
13
|
+
|
|
14
|
+
The Go backend provides an interface for forwarding the incoming RPC calls to
|
|
15
|
+
the appropriate backend service.
|
|
16
|
+
|
|
17
|
+
# Usage
|
|
18
|
+
|
|
19
|
+
## Go
|
|
20
|
+
|
|
21
|
+
TODO
|
|
22
|
+
|
|
23
|
+
Copy the Go project boilerplate files:
|
|
24
|
+
|
|
25
|
+
- Makefile: implements "make gengo" to generate Go code with protoc.
|
|
26
|
+
- hack/: downloads & builds the necessary protoc-gen-go tools.
|
|
27
|
+
|
|
28
|
+
To generate code for .proto files in your repository:
|
|
29
|
+
|
|
30
|
+
- `git add .` - stage all changes first.
|
|
31
|
+
- `make gengo` - generate the protobuf files.
|
|
32
|
+
|
|
33
|
+
Example of creating & serving a service in Go: (TODO)
|
|
34
|
+
|
|
35
|
+
## TypeScript
|
|
36
|
+
|
|
37
|
+
See the ts-proto README to generate the TypeScript for your protobufs.
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { RpcClient, WebSocketConn } from 'starpc'
|
|
41
|
+
import { DemoServiceClientImpl } from './demo'
|
|
42
|
+
|
|
43
|
+
const ws = new WebSocket('ws://localhost:5000/demo')
|
|
44
|
+
const channel = new WebSocketConn(ws)
|
|
45
|
+
const rpc = new RpcClient(channel)
|
|
46
|
+
const demoServiceClient = new DemoServiceClientImpl(rpc)
|
|
47
|
+
|
|
48
|
+
const result = await demoServiceClient.DemoEcho({
|
|
49
|
+
msg: "Hello world!"
|
|
50
|
+
})
|
|
51
|
+
console.log('output', result.msg)
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`WebSocketConn` uses [js-libp2p-mplex] to multiplex streams over the WebSocket.
|
|
55
|
+
|
|
56
|
+
[js-libp2p-mplex]: https://github.com/libp2p/js-libp2p-mplex
|
package/package.json
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "starpc",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Streaming protobuf RPC service protocol over any two-way channel.",
|
|
5
|
+
"repository": "github:paralin/starpc",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Christian Stewart",
|
|
9
|
+
"email": "christian@aperture.us",
|
|
10
|
+
"url": "http://github.com/paralin"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {},
|
|
13
|
+
"prettier": {},
|
|
14
|
+
"dependencies": {}
|
|
15
|
+
}
|