Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tour improvements #160

Merged
merged 5 commits into from
Oct 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions docs/tour.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -85,21 +85,36 @@

To do resilience experiments later on, you can restart the runtime (without losing state) with `docker restart restate_dev`.

Discover the services:
Register the services:

Now, we need to tell Restate where the service runs.

Check warning on line 90 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L90

[Google.We] Try to avoid using first-person plural like 'we'.
Raw output
{"message": "[Google.We] Try to avoid using first-person plural like 'we'.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 90, "column": 6}}}, "severity": "WARNING"}
gvdongen marked this conversation as resolved.
Show resolved Hide resolved

<Tabs groupId="operating-systems">
<TabItem value="lin" label="Linux">

You do this by sending a request to the endpoint of the runtime at `http://localhost:8081/endpoints`
and providing it with the endpoint of the service `http://localhost:8080`.

```shell
curl -X POST http://localhost:8081/endpoints -H 'content-type: application/json' -d '{"uri": "http://localhost:8080"}'
```

Restate then sends a request to the service endpoint to ask which services and methods run behind this endpoint.
This way Restate keeps track of which services run where (including of the method signatures),

Check notice on line 103 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L103

[Google.Parens] Use parentheses judiciously.
Raw output
{"message": "[Google.Parens] Use parentheses judiciously.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 103, "column": 58}}}, "severity": "INFO"}
and knows how to invoke a specific service.
</TabItem>
<TabItem value="mac" label="macOS">

You do this by sending a request to the endpoint of the runtime at `http://localhost:8081/endpoints`
and providing it with the endpoint of the service `http://host.docker.internal:8080`.

```shell
curl -X POST http://localhost:8081/endpoints -H 'content-type: application/json' -d '{"uri": "http://host.docker.internal:8080"}'
```

Restate then sends a request to the service endpoint to ask which services and methods run behind this endpoint.
This way Restate keeps track of which services run where (including of the method signatures),

Check notice on line 116 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L116

[Google.Parens] Use parentheses judiciously.
Raw output
{"message": "[Google.Parens] Use parentheses judiciously.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 116, "column": 58}}}, "severity": "INFO"}
and knows how to invoke a specific service.
</TabItem>
</Tabs>

Expand Down Expand Up @@ -155,15 +170,19 @@
Mimic adding a ticket to a cart, by calling `UserSession/addTicket` as follows:

```shell
curl -X POST http://localhost:9090/UserSession/addTicket -H 'content-type: application/json' -d '{"key": "123", "request": "456"}'
curl -X POST http://localhost:9090/UserSession/addTicket \
-H 'content-type: application/json' \
-d '{"key": "123", "request": "456"}'
```

If this prints out `true`, then you have a working setup.

You can call the `UserSession/checkout` function to proceed with the purchase, as follows:

```shell
curl -X POST http://localhost:9090/UserSession/checkout -H 'content-type: application/json' -d '{"key": "123"}'
curl -X POST http://localhost:9090/UserSession/checkout \
-H 'content-type: application/json' \
-d '{"key": "123"}'
```

In `src/app`, you find the skeletons of the services where you can start implementing your app.
Expand All @@ -174,7 +193,8 @@
Two types of Restate services exist:
1. **Keyed service**:
All service invocations are sharded on a user-defined key.
Per key there is at most one concurrent invocation.
Function invocations of keyed services are serialized on the user-defined key.

Check notice on line 196 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L196

[write-good.E-Prime] Try to avoid using 'are'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'are'.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 196, "column": 40}}}, "severity": "INFO"}

Check warning on line 196 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L196

[write-good.Passive] 'are serialized' may be passive voice. Use active voice if you can.
Raw output
{"message": "[write-good.Passive] 'are serialized' may be passive voice. Use active voice if you can.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 196, "column": 40}}}, "severity": "WARNING"}

Check notice on line 196 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L196

[Google.Passive] In general, use active voice instead of passive voice ('are serialized').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('are serialized').", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 196, "column": 40}}}, "severity": "INFO"}
Therefore, at most one function can run at a time for a given key within such service.

Check warning on line 197 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L197

[write-good.TooWordy] 'Therefore' is too wordy.
Raw output
{"message": "[write-good.TooWordy] 'Therefore' is too wordy.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 197, "column": 1}}}, "severity": "WARNING"}
2. **Unkeyed service**:
No key defined.
No concurrency guarantees or limitations.
Expand All @@ -187,9 +207,9 @@

```typescript
const serviceRouter = restate.router({
hello: async () => { ... },
hello: async (ctx: restate.RpcContext, request: Request) => { ... },
callMe: async (ctx: restate.RpcContext) => { ... },
maybe: async (ctx: restate.RpcContext, request: Request) => { ... }
maybe: async () => { ... }
});
```

Expand All @@ -204,10 +224,10 @@

```typescript
const keyedServiceRouter = restate.keyedRouter({
hello: async () => { ... },
callMe: async (ctx: restate.RpcContext) => { ... },
maybe: async (ctx: restate.RpcContext, key: string) => { ... },
withSomething: async (ctx: restate.RpcContext, key: string, request: Request) => { ... }
hello: async (ctx: restate.RpcContext, key: string, request: Request) => { ... },
callMe: async (ctx: restate.RpcContext, key: string) => { ... },
maybe: async (ctx: restate.RpcContext) => { ... },
withSomething: async () => { ... }
});
```

Expand All @@ -219,6 +239,12 @@

You can choose the parameter names differently.

As mentioned, for keyed services there can be at most one concurrent invocation at the service level.

Check notice on line 242 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L242

[write-good.E-Prime] Try to avoid using 'be'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'be'.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 242, "column": 44}}}, "severity": "INFO"}
So this means that if there is a call to `hello()`, then a call to `callMe()`, then `callMe()` will wait in line until `hello()` has finished, if and only if both were invoked with the same value of `key`.

Check failure on line 243 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L243

[write-good.So] Don't start a sentence with 'So '.
Raw output
{"message": "[write-good.So] Don't start a sentence with 'So '.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 243, "column": 1}}}, "severity": "ERROR"}

Check notice on line 243 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L243

[write-good.E-Prime] Try to avoid using 'is'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'is'.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 243, "column": 29}}}, "severity": "INFO"}

Check warning on line 243 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L243

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 243, "column": 96}}}, "severity": "WARNING"}

Check warning on line 243 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L243

[write-good.Weasel] 'only' is a weasel word!
Raw output
{"message": "[write-good.Weasel] 'only' is a weasel word!", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 243, "column": 151}}}, "severity": "WARNING"}

Check notice on line 243 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L243

[write-good.E-Prime] Try to avoid using 'were'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'were'.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 243, "column": 164}}}, "severity": "INFO"}

Check warning on line 243 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L243

[write-good.Passive] 'were invoked' may be passive voice. Use active voice if you can.
Raw output
{"message": "[write-good.Passive] 'were invoked' may be passive voice. Use active voice if you can.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 243, "column": 164}}}, "severity": "WARNING"}

Check notice on line 243 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L243

[Google.Passive] In general, use active voice instead of passive voice ('were invoked').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('were invoked').", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 243, "column": 164}}}, "severity": "INFO"}
until the call to `hello()` has finished successfully.

Check warning on line 244 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L244

[write-good.Weasel] 'successfully' is a weasel word!
Raw output
{"message": "[write-good.Weasel] 'successfully' is a weasel word!", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 244, "column": 42}}}, "severity": "WARNING"}
This also counts for the `maybe()` and `withSomething()` functions,
even though the key parameter was omitted from their signatures.

Check notice on line 246 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L246

[write-good.E-Prime] Try to avoid using 'was'.
Raw output
{"message": "[write-good.E-Prime] Try to avoid using 'was'.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 246, "column": 31}}}, "severity": "INFO"}

Check warning on line 246 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L246

[write-good.Passive] 'was omitted' may be passive voice. Use active voice if you can.
Raw output
{"message": "[write-good.Passive] 'was omitted' may be passive voice. Use active voice if you can.", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 246, "column": 31}}}, "severity": "WARNING"}

Check notice on line 246 in docs/tour.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/tour.mdx#L246

[Google.Passive] In general, use active voice instead of passive voice ('was omitted').
Raw output
{"message": "[Google.Passive] In general, use active voice instead of passive voice ('was omitted').", "location": {"path": "docs/tour.mdx", "range": {"start": {"line": 246, "column": 31}}}, "severity": "INFO"}

You export the `service` API by creating a service API instance which specifies under which path the service is reachable:

```typescript
Expand Down Expand Up @@ -490,7 +516,9 @@

Call the `expireTicket` function with:
```shell
curl -X POST http://localhost:9090/UserSession/expireTicket -H 'content-type: application/json' -d '{"key": "123", "request": "456"}'
curl -X POST http://localhost:9090/UserSession/expireTicket \
-H 'content-type: application/json' \
-d '{"key": "123", "request": "456"}'
```

Have a look at the logs again to see what happened:
Expand Down Expand Up @@ -1312,7 +1340,7 @@
<TabItem value="mac" label="macOS">

```shell
docker run --name restate_dev --rm -d -e RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://host.docker.internal:4317 -p 8081:8081 -p 9091:9091 -p 9090:9090 ghcr.io/restatedev/restate-dist:VAR::RESTATE_DIST_VERSION
docker run --name restate_dev --rm -d -e RESTATE_OBSERVABILITY__TRACING__ENDPOINT=http://host.docker.internal:4317 -p 8081:8081 -p 9091:9091 -p 9090:9090 -p 5432:5432 ghcr.io/restatedev/restate-dist:VAR::RESTATE_DIST_VERSION
```

</TabItem>
Expand Down