@@ -32,7 +32,8 @@ First, install the dependencies:
32
32
npm install
33
33
```
34
34
35
- ## Durable RPC, Idempotency and Concurrency
35
+ ## Durable RPC, Idempotency and Concurrency
36
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/durablerpc/express_app.ts )
36
37
37
38
This example shows:
38
39
- ** Durable RPC** : once a request has reached Restate, it is guaranteed to be processed
@@ -73,6 +74,7 @@ Restate deduplicated the request (with the reservation ID as idempotency key) an
73
74
</details >
74
75
75
76
## (Delayed) Message Queue
77
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/queue/task_submitter.ts )
76
78
77
79
Use Restate as a queue. Schedule tasks for now or later and ensure the task is only executed once.
78
80
@@ -83,6 +85,7 @@ Use Restate as a queue. Schedule tasks for now or later and ensure the task is o
83
85
- [ Async Task Worker] ( src/queue/async_task_worker.ts ) : gets invoked by Restate for each task in the queue.
84
86
85
87
## Webhook Callbacks
88
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/webhookcallbacks/webhook_callback_router.ts )
86
89
87
90
This example processes webhook callbacks from a payment provider.
88
91
@@ -92,6 +95,7 @@ This turns handlers into durable event processors that ensure the event is proce
92
95
You don't need to do anything special!
93
96
94
97
## Convert Sync Tasks to Async
98
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/webhookcallbacks/webhook_callback_router.ts )
95
99
96
100
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** .
97
101
@@ -118,6 +122,7 @@ Have a look at the logs to see how the execution switches from synchronously wai
118
122
</details >
119
123
120
124
## Payment Signals
125
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/signalspayments/payment_service.ts )
121
126
122
127
This example issues a payment request to Stripe.
123
128
When calling Stripe, the result often comes synchronously as a response API call.
@@ -189,6 +194,7 @@ A few notes:
189
194
</details >
190
195
191
196
## Sagas
197
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/sagas/booking_workflow.ts )
192
198
193
199
An example of a trip reservation workflow, using the saga pattern to undo previous steps in case of an error.
194
200
@@ -251,6 +257,7 @@ Flight 51e219f8-eb34-4384-a5ff-88607e89c220 cancelled
251
257
</details >
252
258
253
259
## Stateful Actors and State Machines
260
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/statefulactors/machine_operator.ts )
254
261
255
262
This example implements a State Machine with a Virtual Object.
256
263
@@ -326,6 +333,7 @@ A failure happened!
326
333
</details >
327
334
328
335
## Payment State Machines
336
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/statemachinepayments/payment_service.ts )
329
337
330
338
This example shows how to build a reliable payment state machine.
331
339
@@ -399,6 +407,8 @@ status "CANCELLED"
399
407
</details >
400
408
401
409
## Scheduling Tasks
410
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/schedulingtasks/payment_reminders.ts )
411
+
402
412
This example processes failed payment events from a payment provider.
403
413
The service reminds the customer for 3 days to update their payment details, and otherwise escalates to support.
404
414
@@ -408,6 +418,7 @@ The handler calls itself three times in a row after a delay of one day, and then
408
418
Restate tracks the timer across failures, and triggers execution.
409
419
410
420
## Parallelizing work
421
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/parallelizework/fan_out_worker.ts )
411
422
412
423
This example shows how to use the Restate SDK to ** execute a list of tasks in parallel and then gather their result** .
413
424
Also known as fan-out, fan-in.
@@ -419,6 +430,7 @@ Restate guarantees and manages the execution of all the subtasks across failures
419
430
You can run this on FaaS infrastructure, like AWS Lambda, and it will scale automatically.
420
431
421
432
## Transactional Event Processing
433
+ [ <img src =" https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg " >] ( src/eventtransactions/user_feed.ts )
422
434
423
435
Processing events (from Kafka) to update various downstream systems.
424
436
- Durable side effects with retries and recovery of partial progress
@@ -493,6 +505,7 @@ You can try it out by killing Restate or the service halfway through processing
493
505
< /details>
494
506
495
507
# # Event Enrichment / Joins
508
+ [< img src= " https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg" > ](src/eventenrichment/package_tracker.ts)
496
509
497
510
This example shows an example of:
498
511
- ** Event enrichment** over different sources: RPC and Kafka
@@ -576,6 +589,7 @@ You can see how the state was enriched by the initial RPC event and the subseque
576
589
< /details>
577
590
578
591
# # Durable Promises
592
+ [< img src= " https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg" > ](src/durablepromise)
579
593
580
594
The Durable Promises implemented in this example work like regular futures/promises,
581
595
but are durable cross processes and failures.
@@ -666,6 +680,7 @@ optionally passing `[promise-id] [restateUri]` as parameters.
666
680
</details>
667
681
668
682
## Priority queue
683
+ [<img src="https://raw.githubusercontent.com/restatedev/img/refs/heads/main/show-code.svg">](src/priorityqueue)
669
684
670
685
An example of implementing your own priority queue using Restate state and awakeables.
671
686
0 commit comments