@latticexyz/services 0.9.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 ADDED
@@ -0,0 +1,53 @@
1
+ # MUD services
2
+
3
+ This package contains the source code for MUD services for enhanced interactions with on-chain ECS state -- ECS Snapshot Service and ECS Stream Service.
4
+
5
+ [ECS State Snapshot Service](./cmd/ecs-snapshot/main.go) -- The service's function is to compute and save ECS state from the chain via "snapshots", such that a client can perform an initial sync to the ECS world state without having to process all ECS state changes (in the form of events).
6
+
7
+ [ECS Stream Service](./cmd/ecs-stream/main.go) -- The service's function is to serve as a multiplexer, subscribing to a feed of data from a Geth-based chain and allowing multiple clients to selectively subscribe to subsets of the data that they care about.
8
+
9
+ ## Local setup
10
+
11
+ ### Generating protobuf files
12
+
13
+ The package has the protobuf files checked in, but in case you want to regenerate those (based on an updated `.proto` file for instance)
14
+
15
+ ```
16
+ make protoc
17
+ ```
18
+
19
+ The services are written in Go, so to compile and run the service locally you will need Golang installed locally.
20
+
21
+ 1. Install Go
22
+ 2. Build the source `make build`
23
+ 3. Run whichever binary
24
+
25
+ ```
26
+ make run-ecs-stream WS_URL=<websocket URL>
27
+ ```
28
+
29
+ or
30
+
31
+ ```
32
+ make run-ecs-snapshot WS_URL=<websocket URL>
33
+ ```
34
+
35
+ The websocket URLs default to a local node -- `ws://localhost:8545`.
36
+
37
+ ### Support for gRPC-web
38
+
39
+ In order to receive requests from gRPC-web (which are just POST routes), we need to wrap the gRPC server in a http listener server behind a "proxy". The services use a wrapper Go library to wrap the gRPC server and additionally expose an HTTP server which will listen for gRPC-web requests and do the proxying.
40
+
41
+ ## Docker / Kubernetes setup
42
+
43
+ The service can be built and used within a Kubernetes cluster (via a resource that can pull the container image). To create the image, use the local `Dockerfile` and run, for example
44
+
45
+ ```
46
+ docker build -f Dockerfile.snapshot --tag ghcr.io/latticexyz/mud-ecs-snapshot:<YOUR_TAG>
47
+ ```
48
+
49
+ This will build the service and tag the image such that you can push to a container registry, for example
50
+
51
+ ```
52
+ docker push ghcr.io/latticexyz/mud-ecs-snapshot:<YOUR_TAG>
53
+ ```
Binary file
package/bin/ecs-stream ADDED
Binary file
File without changes
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@latticexyz/services",
3
+ "license": "MIT",
4
+ "version": "0.9.0",
5
+ "description": "MUD services for enhanced interactions with on-chain ECS state",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/latticexyz/mud.git",
9
+ "directory": "packages/services"
10
+ },
11
+ "scripts": {
12
+ "prepare": "make build",
13
+ "docs": "typedoc . --readme README.md",
14
+ "test": "echo 'todo: add tests'",
15
+ "link": "yarn link"
16
+ },
17
+ "devDependencies": {
18
+ "@protobuf-ts/grpcweb-transport": "^2.7.0",
19
+ "@protobuf-ts/plugin": "^2.7.0",
20
+ "@protobuf-ts/runtime-rpc": "^2.7.0",
21
+ "typedoc": "^0.23.10"
22
+ },
23
+ "peerDependencies": {
24
+ "@protobuf-ts/grpcweb-transport": "^2.7.0",
25
+ "@protobuf-ts/plugin": "^2.7.0",
26
+ "@protobuf-ts/runtime-rpc": "^2.7.0"
27
+ },
28
+ "gitHead": "40718ea9955e61196942d040189adec464500446"
29
+ }