
How does Restate help?
- Restate lets you schedule the tasks asynchronously and guarantees that all tasks will run, with retries and recovery on failures.
- Restate turns Promises/Futures into durable, distributed constructs that are persisted in Restate and can be recovered and awaited on another process.
- You can deploy the subtask executors on serverless infrastructure, like AWS Lambda, to let them scale automatically. The main task, that is idle while waiting on the subtasks, gets suspended until it can make progress.
Example
The example implements a worker service:- It splits a task into subtasks.
- It schedules all the subtasks. Each subtask results in a promise that gets added to a list.
- The result is gathered by waiting for all promises to resolve.
run
handler will then suspend while it waits for all subtasks to finish.
Restate will then resume the handler when all subtasks are done.
ctx.run
actions.
Running the example
1
Download the example
2
Start the Restate Server
3
Start the Service
4
Register the services
5
Send a request
6
Check the service logs
See how all tasks get spawned in parallel, finish at different times, and then get aggregated.
Related resources
- Concurrent tasks docs: TS / Java/Kotlin / Python / Go / Rust