|
1 | 1 | # Go Patterns and Use Cases
|
2 | 2 |
|
| 3 | +Common tasks and patterns implemented with Restate: |
| 4 | + |
3 | 5 | #### Communication
|
4 | 6 | - **[Durable RPC, Idempotency & Concurrency](README.md#durable-rpc-idempotency-and-concurrency)**: Use programmatic clients to call Restate handlers. Add idempotency keys for deduplication. [<img src="https://raw.githubusercontent.com/restatedev/img/refs/heads/main/play-button.svg" width="16" height="16">](src/durablerpc/client/client.go)
|
5 | 7 | - **[(Delayed) Message Queue](README.md#delayed-message-queue)**: Restate as a queue: Send (delayed) events to handlers. Optionally, retrieve the response later. [<img src="https://raw.githubusercontent.com/restatedev/img/refs/heads/main/play-button.svg" width="16" height="16">](src/queue/client/tasksubmitter.go)
|
|
15 | 17 | - **[Parallelizing Work](README.md#parallelizing-work)**: Execute a list of tasks in parallel and then gather their result. [<img src="https://raw.githubusercontent.com/restatedev/img/refs/heads/main/play-button.svg" width="16" height="16">](src/parallelizework/fanoutworker.go)
|
16 | 18 |
|
17 | 19 | #### Event processing
|
18 |
| -- **[Event Enrichment / Joins](README.md#event-enrichment--joins)**: Stateful functions/actors connected to Kafka and callable over RPC. [<img src="https://raw.githubusercontent.com/restatedev/img/refs/heads/main/play-button.svg" width="16" height="16">](src/eventenrichment/packagetracker.go) |
19 | 20 | - **[Transactional Event Processing](README.md#transactional-event-processing)**: Process events from Kafka to update various downstream systems in a transactional way. [<img src="https://raw.githubusercontent.com/restatedev/img/refs/heads/main/play-button.svg" width="16" height="16">](src/eventtransactions/userfeed.go)
|
| 21 | +- **[Event Enrichment / Joins](README.md#event-enrichment--joins)**: Stateful functions/actors connected to Kafka and callable over RPC. [<img src="https://raw.githubusercontent.com/restatedev/img/refs/heads/main/play-button.svg" width="16" height="16">](src/eventenrichment/packagetracker.go) |
20 | 22 |
|
21 | 23 | ## Durable RPC, Idempotency and Concurrency
|
22 | 24 |
|
23 |
| -This example shows an example of: |
| 25 | +This example shows: |
24 | 26 | - **Durable RPC**: once a request has reached Restate, it is guaranteed to be processed
|
25 | 27 | - **Exactly-once processing**: Ensure that duplicate requests are not processed multiple times via idempotency keys
|
26 | 28 |
|
@@ -75,6 +77,16 @@ This turns handlers into durable event processors that ensure the event is proce
|
75 | 77 |
|
76 | 78 | You don't need to do anything special!
|
77 | 79 |
|
| 80 | +## Scheduling Tasks |
| 81 | +This example processes failed payment events from a payment provider. |
| 82 | +The service reminds the customer for 3 days to update their payment details, and otherwise escalates to support. |
| 83 | + |
| 84 | +To schedule the reminders, the handler uses Restate's durable timers and delayed calls. |
| 85 | +The handler calls itself three times in a row after a delay of one day, and then stops the loop and calls another handler. |
| 86 | + |
| 87 | +Restate tracks the timer across failures, and triggers execution. |
| 88 | + |
| 89 | + |
78 | 90 | ## Convert Sync Tasks to Async
|
79 | 91 |
|
80 | 92 | This example shows how to use the Restate SDK to **kick of a synchronous task and turn it into an asynchronous one if it takes too long**.
|
@@ -166,6 +178,7 @@ Have a look at the logs to see the cancellations of the flight and car booking i
|
166 | 178 | 2025/01/06 16:16:02 INFO Refunded payment: e4eac4a9-47c9-4087-9502-cb0fff1218c6
|
167 | 179 | 2025/01/06 16:16:02 INFO Invocation completed successfully method=BookingWorkflow/Run invocationID=inv_17l9ZLwBY3bz6HEIybYB6Rh9SbV6khuc0N
|
168 | 180 | ```
|
| 181 | + |
169 | 182 | </details>
|
170 | 183 | </details>
|
171 | 184 |
|
@@ -253,14 +266,6 @@ echo "executing..."
|
253 | 266 | </details>
|
254 | 267 | </details>
|
255 | 268 |
|
256 |
| -## Scheduling Tasks |
257 |
| -This example processes failed payment events from a payment provider. |
258 |
| -The service reminds the customer for 3 days to update their payment details, and otherwise escalates to support. |
259 |
| - |
260 |
| -To schedule the reminders, the handler uses Restate's durable timers and delayed calls. |
261 |
| -The handler calls itself three times in a row after a delay of one day, and then stops the loop and calls another handler. |
262 |
| - |
263 |
| -Restate tracks the timer across failures, and triggers execution. |
264 | 269 |
|
265 | 270 | ## Parallelizing work
|
266 | 271 |
|
|
0 commit comments