Server for Web
Server uses gRPC to provide an API that Clients can connect to. Since it is currently impossible to implement the HTTP/2 gRPC in some browsers, Envoy is required for web. For more details: gRPC-web
This page shows how to start the Server for web. Overall structure is as follows:
Browser Envoy Server
┌────────┐ ┌──────────────┐ ┌───────────┐
│gRPC-web├─HTTP1.1─┤gRPC-web Proxy├─HTTP2─┤gRPC Server│
└────────┘ └──────────────┘ └───────────┘
Start Server with Envoy
Configuring Envoy by hand with its config file is cumbersome, but using Docker Compose makes it easy.
NOTE: If docker compose is not installed, install it: Install Docker Compose
First, download all manifests files from docker folder. Then, execute the following command in the folder containing the downloaded file.
$ docker-compose up --build -d
Starting yorkie ... done
Starting envoy ... done
This will launch Yorkie(Server) and envoy containers on your environment.
$ docker ps
IMAGE COMMAND PORTS NAMES
grpcweb:envoy "/usr/local/bin/envo…" 0.0.0.0:8080->9090/tcp envoy
yorkieteam/yorkie:latest "yorkie server --ena…" 0.0.0.0:11101-11103->11101-11103/tcp yorkie
Then, the ports of the services are bound to the host environment.
- 8080: gRPC-web port for SDK
- 9090: gRPC-web port for Web Admin(Yorkie House)
- 11101: gRPC port for SDK
- 11102: HTML port for profiling Server
- 11103: gRPC port for admin Server
NOTE: Server stores its data using an in-memory DB, which does not provide durability. If you want to store data permanently, please refer to Running Server With MongoDB
Now, let’s create a Client with address localhost:8080
.
const client = new yorkie.Client('localhost:8080');
await client.activate();
Next, let’s take a look at the JS SDK.