Skip to content

Commit

Permalink
Cleanup: Unify MacOS and Linux Docker commands, use CLI for registrat…
Browse files Browse the repository at this point in the history
…ion, terminology (#82)

* Unify MacOS and Linux Docker commands and use CLI for registration

* Add note on service deployment URI for docker deployment of Restate

* Feedback
  • Loading branch information
gvdongen authored Feb 1, 2024
1 parent b1f87aa commit 8779399
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 61 deletions.
93 changes: 51 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,52 +45,61 @@ The Discord server is also the perfect place for sharing your feedback with us,

## Running the examples

The readme for each example will explain how to get it running. Once the example is running, it needs to be discovered by an instance of the Restate runtime.

### Launching the runtime

Have a look at how to start up the runtime in a Docker container in [this repository]* or run the following commands:

- For MacOS:
```shell
docker run --name restate_dev --rm -p 8080:8080 -p 9070:9070 -p 9071:9071 docker.io/restatedev/restate:latest
```
- For Linux:
```shell
docker run --name restate_dev --rm --network=host docker.io/restatedev/restate:latest
```

### Connect runtime and services

Once the runtime is up, let it discover the services of the example by executing:

- For MacOS:
```shell
curl -X POST http://localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:9080"}'
```
- For Linux:
```shell
curl -X POST http://localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}'
```
The readme for each example will explain how to get it running. Once the services of the example are running, the deployment needs to be registered in Restate.

### Launching the Restate Server

**NOTE:** Some examples can be run with Docker Compose. For those, you can ignore this section.

For running Restate locally and downloading the binaries, have a look at the options on the [`Get Restate` page](https://restate.dev/get-restate/).

- To run Restate in a Docker container:
```shell
docker run --name restate_dev --rm -p 8080:8080 -p 9070:9070 -p 9071:9071 --add-host=host.docker.internal:host-gateway docker.io/restatedev/restate:latest
```
- To run Restate with `npx`:
```shell
npx @restatedev/restate-server@latest
```
- To run Restate with Homebrew:
```
brew install restatedev/tap/restate-server
restate-server
```

### Register the deployment in Restate

Once Restate is up, register the deployment in Restate by executing:

- Via the [CLI](https://docs.restate.dev/restate/cli):
```shell
restate dp register localhost:9080
```
- Via `curl`:
```shell
curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://localhost:9080"}'
```

When running Restate with Docker, use `host.docker.internal` instead of `localhost` for the service deployment URI.

This should give you the following output in case of the ticket reservation example:
```json
{
"id": "bG9jYWxob3N0OjgwODAv",
"services": [
{
"name": "UserSession",
"revision": 1
},
{
"name": "TicketDb",
"revision": 1
},
{
"name": "CheckoutProcess",
"revision": 1
}
]
"id": "bG9jYWxob3N0OjgwODAv",
"services": [
{
"name": "UserSession",
"revision": 1
},
{
"name": "TicketDb",
"revision": 1
},
{
"name": "CheckoutProcess",
"revision": 1
}
]
}
```

Expand Down
16 changes: 2 additions & 14 deletions typescript/dynamic-workflow-executor/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,6 @@ In a real deployment, this would need to be a shared storage, like S3.

## Running the example

### Deploy Restate Server

Start the restate server via `npx`:
```shell
npx @restatedev/restate-server@latest
```

### Deploy the services

Install the dependencies
Expand Down Expand Up @@ -83,14 +76,9 @@ Run workflow service:
npm run workflow-service
```

Register the services at the Restate Server, using the CLI:
Now [launch the Restate Server](../../README.md#launching-the-restate-server) and [register the services](../../README.md#register-the-deployment-in-restate).

```shell
npx @restatedev/restate dp reg localhost:9080
npx @restatedev/restate dp reg localhost:9081
npx @restatedev/restate dp reg localhost:9082
npx @restatedev/restate dp reg localhost:9083
```
Make sure you register all four services with the following ports: `9080`, `9081`, `9082` and `9083`.

### OPTIONAL: Install and run stable diffusion server

Expand Down
2 changes: 1 addition & 1 deletion typescript/ecommerce-store/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ npm run app
The services are now running.
See [how to launch the runtime](../../README.md#launching-the-runtime) and [how to discover services](../../README.md#connect-runtime-and-services) for details.
See [how to launch the Restate Server](../../README.md#launching-the-restate-server) and [how to register services](../../README.md#register-the-deployment-in-restate) for details.
Run the web app:
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion typescript/ecommerce-store/deployment/knative/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can visit the web app at http://localhost:3000
kubectl port-forward -n shopping-cart svc/restate-runtime 8080:8080 9070:9070 9071:9071
```

7. Execute the service discovery:
7. Register the deployment in Restate:

```shell
curl localhost:9070/deployments -H 'content-type: application/json' -d '{"uri": "http://services.shopping-cart.svc.cluster.local"}'
Expand Down
2 changes: 1 addition & 1 deletion typescript/payment-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ npm run build
npm run app
```

Now [launch the runtime](../../README.md#launching-the-runtime) and [discover the services](../../README.md#connect-runtime-and-services).
Now [launch the Restate Server](../../README.md#launching-the-restate-server) and [register the services](../../README.md#register-the-deployment-in-restate).

Make a sample payment. The 'key' parameter is the idempotency token.

Expand Down
4 changes: 2 additions & 2 deletions typescript/ticket-reservation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ npm run app
The user session service, ticket service and checkout service are now up and running!
### Launch Restate and discover services
### Launch Restate and register services
Now [launch the runtime](../../README.md#launching-the-runtime) and [discover the services](../../README.md#connect-runtime-and-services).
Now [launch the Restate Server](../../README.md#launching-the-restate-server) and [register the services](../../README.md#register-the-deployment-in-restate).
### Call the service
Expand Down

0 comments on commit 8779399

Please sign in to comment.