Skip to content

Commit

Permalink
Upgrade Docusaurus to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
pcholakov committed Dec 14, 2023
1 parent 1c346f4 commit 4813697
Show file tree
Hide file tree
Showing 9 changed files with 3,470 additions and 2,137 deletions.
4 changes: 4 additions & 0 deletions docs/restate/tracing.md → docs/restate/tracing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ sidebar_position: 4
description: "Find out how to export traces of your invocations."
---

import Tabs from '@theme/Tabs';

Check notice on line 6 in docs/restate/tracing.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/restate/tracing.mdx#L6

[Google.Semicolons] Use semicolons judiciously.
Raw output
{"message": "[Google.Semicolons] Use semicolons judiciously.", "location": {"path": "docs/restate/tracing.mdx", "range": {"start": {"line": 6, "column": 31}}}, "severity": "INFO"}
import TabItem from '@theme/TabItem';

Check notice on line 7 in docs/restate/tracing.mdx

View workflow job for this annotation

GitHub Actions / vale

[vale] docs/restate/tracing.mdx#L7

[Google.Semicolons] Use semicolons judiciously.
Raw output
{"message": "[Google.Semicolons] Use semicolons judiciously.", "location": {"path": "docs/restate/tracing.mdx", "range": {"start": {"line": 7, "column": 37}}}, "severity": "INFO"}

# Tracing

Restate supports the following tracing features:
Expand Down Expand Up @@ -44,6 +47,7 @@ jaegertracing/all-in-one:1.46
```

Then launch Restate with the tracing endpoint defined as an environment variable:

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

Expand Down
4 changes: 2 additions & 2 deletions docs/services/sdk/kafka.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ public void handle(RestateContext ctx, Event event) {
}
```

<details><summary>Alternative: vanilla gRPC</summary>
<details>
<summary>Alternative: vanilla gRPC</summary>

```java
import dev.restate.generated.Event;
Expand All @@ -218,7 +219,6 @@ public void handle(Event event, StreamObserver<Empty> responseObserver) {
responseObserver.onCompleted();
}
```

</details>

:::tip Combining RPC and Kafka within a service
Expand Down
4 changes: 2 additions & 2 deletions docs/services/sdk/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ message GreetResponse {

To understand the Restate-specific parts of this Protobuf definition, have a look at the documentation [here](/services/service_type#restate-service-contract).

<details><summary>Alternative: vanilla gRPC</summary>
<details>
<summary>Alternative: vanilla gRPC</summary>

Restate's proto code generator makes the generated code more polished for writing Restate services.
However, it is also possible to use the vanilla generated protobuf code by `protoc-gen-grpc-java`, in case you prefer this.
Expand Down Expand Up @@ -347,7 +348,6 @@ public class Greeter extends GreeterGrpc.GreeterImplBase implements RestateBlock

</details>


</TabItem>
</Tabs>

Expand Down
4 changes: 2 additions & 2 deletions docs/services/sdk/restate-context.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public class Greeter extends GreeterRestate.GreeterRestateImplBase {
Have a look at the [JavaDocs](https://javadoc.io/doc/dev.restate/sdk-api/latest/dev/restate/sdk/RestateContext.html) for an overview of what you can do with the Restate context.
:::

<details><summary>Alternative: vanilla gRPC</summary>
<details>
<summary>Alternative: vanilla gRPC</summary>

If you do not use Restate's generated protobuf code, you can access the restate context as follows

Expand All @@ -78,7 +79,6 @@ RestateContext ctx = restateContext();

</details>


</TabItem>
</Tabs>

Expand Down
9 changes: 6 additions & 3 deletions docs/services/sdk/service-communication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ GreetResponse response = client.greet(req).await();
```


<details><summary>Alternative: vanilla gRPC</summary>
<details>
<summary>Alternative: vanilla gRPC</summary>

You can do request-response calls via `ctx.call` by supplying it with the gRPC method descriptor and request, by using the generated Protobuf code.
In this example, the `Greet` function requires a `Request` Protobuf message as input with a single `name` parameter.
Expand Down Expand Up @@ -148,7 +149,8 @@ client.oneWay().greet(req);
```


<details><summary>Alternative: vanilla gRPC</summary>
<details>
<summary>Alternative: vanilla gRPC</summary>

You can do one-way calls via `ctx.oneWayCall` by supplying it with the gRPC method descriptor and request, by using the generated Protobuf code.
In this example, the `Greet` function requires a `Request` Protobuf message as input with a single `name` parameter.
Expand Down Expand Up @@ -209,7 +211,8 @@ var req = GreetRequest.newBuilder().setName("Pete").build();
client.delayed(Duration.ofSeconds(1)).greet(req);
```

<details><summary>Alternative: vanilla gRPC</summary>
<details>
<summary>Alternative: vanilla gRPC</summary>

You can do delayed calls via `ctx.delayedCall` by supplying it with the gRPC method descriptor and request, by using the generated Protobuf code.
In this example, the `Greet` function requires a `Request` Protobuf message as input with a single `name` parameter.
Expand Down
75 changes: 50 additions & 25 deletions docs/tour.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,8 @@ The Restate logs will show the new service registrations taking place.

<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">
<details><summary>Show the runtime logs</summary>
<details>
<summary>Show the runtime logs</summary>

```
2023-08-15T13:24:52.879977Z INFO restate_schema_impl::schemas_impl
Expand All @@ -266,7 +267,8 @@ For MacOS users, the address will be `http://host.docker.internal:9080/`.
</TabItem>

<TabItem value="java" label="Java">
<details><summary>Show the runtime logs</summary>
<details>
<summary>Show the runtime logs</summary>

```
2023-12-06T21:06:02.404764Z INFO restate_schema_impl::schemas_impl
Expand Down Expand Up @@ -557,7 +559,8 @@ Try it out by running the services via `npm run app` and send a request to `User

Have a look at the SDK and runtime logs, to see how the ingress request triggers the execution of the `addTicket` and `reserve` functions.

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>

```log
[restate] [2023-08-15T20:53:51.026Z] DEBUG: [UserSession/addTicket] [K1qex52CPYkBiiHDd1Z6crtc63up0wAD] : Invoking function.
Expand Down Expand Up @@ -598,7 +601,8 @@ Try it out by running the services via `./gradlew run` and send a request to `ex

Have a look at the SDK and runtime logs to see how the ingress request triggers the execution of the `addTicket` and `reserve` functions.

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>

```log
//highlight-next-line
Expand Down Expand Up @@ -662,7 +666,8 @@ Call `UserSession/addTicket` again and have a look at the SDK logs.
Now that the ticket service responds after 35 seconds, you see that the `addTicket` function suspends after 30 seconds.
Once the runtime has received the response, it invokes the `addTicket` function again and the original call finishes.

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>

```log
[restate] [2023-08-15T20:58:25.433Z] DEBUG: [UserSession/addTicket] [K1qex52CPYkBiiHF0pFyZoYvJ5G_WZMF] : Invoking function.
Expand Down Expand Up @@ -707,7 +712,8 @@ Call `UserSession/addTicket` again and have a look at the SDK logs.
Now that the ticket service responds after 65 seconds, you see that the `addTicket` function suspends after 60 seconds.
Once the runtime has received the response, it invokes the `addTicket` function again and the original call finishes.

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>

```log
2023-12-08 11:12:45 [vert.x-eventloop-thread-0] DEBUG RequestHttpServerHandler:157 - Handling request to example.UserSession/AddTicket
Expand Down Expand Up @@ -756,7 +762,8 @@ Make the `UserSession/checkout` function call the `Checkout/checkout` function.
For the request field, you can use a hard-coded string array for now: `["456"]`.
You will fix this later on.

<details><summary>Solution</summary>
<details>
<summary>Solution</summary>

Add the following code to the `UserSession/checkout` function:

Expand Down Expand Up @@ -860,7 +867,8 @@ Therefore, there is no need to await it.
Once you have adapted the code, try it out by calling the `UserSession/addTicket` function, as [explained earlier](#calling-services-from-outside-restate).
In the service logs, you see that the `addTicket` function doesn't wait for a response and finishes earlier than the `reserve` function.

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>

```log
[restate] [2023-08-15T21:09:59.681Z] DEBUG: [UserSession/addTicket] [K1qex52CPYkBiiHJmC53vpTRfQdpRgKE] : Invoking function.
Expand Down Expand Up @@ -897,7 +905,8 @@ Note that `oneWay()` is not an asynchronous operation in the Restate SDK, so the

Once you have adapted the code, restart the service and try it out by calling the `UserSession/addTicket` method as [explained earlier](#calling-services-from-outside-restate). In the service logs, you will see that the `addTicket` method doesn't wait for a response and completes before `reserve` does. The external call will get a response much quicker in this scenario.

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>

```log
//highlight-next-line
Expand Down Expand Up @@ -937,7 +946,8 @@ When you are done with the implementation, send a request to `UserSession/expire
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">

<details><summary>Solution</summary>
<details>
<summary>Solution</summary>

```typescript
const expireTicket = async (
Expand Down Expand Up @@ -979,7 +989,8 @@ Have a look at the logs again to see what happened:

</TabItem>
<TabItem value="java" label="Java">
<details><summary>Solution</summary>
<details>
<summary>Solution</summary>

```java
@Override
Expand Down Expand Up @@ -1076,7 +1087,8 @@ Send an `addTicket` request, as [you did earlier](#running-the-services-and-runt
In the service logs, you can see the `reserve` function processing the sleep, then suspending, and then resuming again after the sleep completed.
The `addTicket` function did a one-way call to the `reserve` function so didn't suspend but just finished its invocation.

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">

Expand Down Expand Up @@ -1151,7 +1163,8 @@ const addTicket = async (
};
```

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>

```log
[restate] [2023-08-15T21:23:49.536Z] DEBUG: [UserSession/addTicket] [K1qex52CPYkBiiHN6ft5nYhPYl4Q3r4Y] : Invoking function.
Expand Down Expand Up @@ -1194,7 +1207,8 @@ public BoolValue addTicket(RestateContext ctx, ReserveTicket request) throws Ter
}
```

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>

```log
2023-12-11 16:53:20 [vert.x-eventloop-thread-0] DEBUG RequestHttpServerHandler:157 - Handling request to example.UserSession/AddTicket
Expand Down Expand Up @@ -1311,7 +1325,8 @@ public BoolValue addTicket(RestateContext ctx, ReserveTicket request) throws Ter

To test it out, put the delay to a lower value, for example 5 seconds, call the `addTicket` function, and see in the logs how the call to `UserSession/expireTicket` is executed 5 seconds later.

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">

Expand Down Expand Up @@ -1507,7 +1522,8 @@ Run the services and call the `addTicket` function, to see the interaction with
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">

<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>

```log
... logs from reserve call ...
Expand All @@ -1529,7 +1545,8 @@ You can store any object in the state as long as the value can be serialized wit
</TabItem>
<TabItem value="java" label="Java">

[//]: # (<details><summary>Show the logs</summary>)
[//]: # (<details>
<summary>Show the logs</summary>)
[//]: # (The Java SDK doesn't currently log anything on get/set state!)
[//]: # (</details>)

Expand Down Expand Up @@ -1682,7 +1699,8 @@ Before you call `unreserve`, you first need to check if the ticket is still hold
Retrieve the state and check if the ticket ID is in there.
If this is the case, then you call `TicketService/unreserve` and remove it from the state.
<details><summary>Solution</summary>
<details>
<summary>Solution</summary>
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">
Expand Down Expand Up @@ -1770,7 +1788,8 @@ If the status isn't set to `TicketStatus.Available`, then return `false`.
Remove the sleep that you added before.
<>
<details><summary>Solution</summary>
<details>
<summary>Solution</summary>
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">
Expand Down Expand Up @@ -1820,7 +1839,8 @@ Call `addTicket` multiple times for the same ID. The first time it returns `true
The function should clear the value of the `"status"` key if it's not on status `TicketStatus.Sold`.
<>
<details><summary>Solution</summary>
<details>
<summary>Solution</summary>
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">
Expand Down Expand Up @@ -1863,7 +1883,8 @@ Try to reserve the same ticket ID multiple times, and see how you are able to re
The function should set the value of the `"status"` key to `TicketStatus.Sold` if it's reserved.
<>
<details><summary>Solution</summary>
<details>
<summary>Solution</summary>
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">
Expand Down Expand Up @@ -1998,7 +2019,8 @@ ctx.sleep(Duration.ofSeconds(61));
Call `UserSession/checkout` and have a look at the logs to see what happens.
<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">
Expand Down Expand Up @@ -2080,7 +2102,8 @@ Assume every ticket costs 40 dollars.
Then execute the payment with the created idempotency key and store the boolean result of the call as the return value of the side effect.
Also return the boolean result at the end of the `checkout` function.
<details><summary>Solution</summary>
<details>
<summary>Solution</summary>
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">
Expand Down Expand Up @@ -2184,7 +2207,8 @@ Once this works, you implement the rest of the checkout workflow:
- use the EmailClient to notify the users of the payment failure.
Prevent duplicate emails during retries by using a side effect.
<details><summary>Solution</summary>
<details>
<summary>Solution</summary>
The `Checkout/checkout` function now looks like the following:
Expand Down Expand Up @@ -2392,7 +2416,8 @@ You now call `paymentClient.failingCall` which fails two times before succeeding
A failing side effect is retried until it succeeds.
Have a look at the logs to see the retries.
<details><summary>Show the logs</summary>
<details>
<summary>Show the logs</summary>
<Tabs groupId="sdk">
<TabItem value="ts" label="TypeScript">
Expand Down
4 changes: 2 additions & 2 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// @ts-check
// Note: type annotations allow type checking and IDEs autocompletion

const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require("prism-react-renderer/themes/dracula");
const lightCodeTheme = require('prism-react-renderer').themes.github;
const darkCodeTheme = require("prism-react-renderer").themes.dracula;
const variableInjector = require("./src/plugins/variable-injector");
const variablesReplacements = require("./restate.config.json");

Expand Down
Loading

0 comments on commit 4813697

Please sign in to comment.