Scheduling & Timers
The Restate SDK includes durable timers. You can use these to let handlers sleep for a specified time, or to schedule a handler to be called at a later time. These timers are resilient to failures and restarts. Restate stores and keeps track of the timers and triggers them on time, even across failures and restarts.
Scheduling Async Tasks
To schedule a handler to be called at a later time, have a look at the documentation on delayed calls.
Durable sleep
To sleep in a Restate application for ten seconds, do the following:
- Java
- Kotlin
ctx.sleep(Duration.ofSeconds(10));
ctx.sleep(10.seconds)
Restate suspends the handler while it is sleeping, to free up resources. This is beneficial for AWS Lambda deployments, since you don't pay for the time the handler is sleeping.
Virtual Objects only process a single invocation at a time, so the Virtual Object will be blocked while sleeping.