Durable Timers - TypeScript SDK
What is a Timer?
A Workflow can set a durable Timer for a fixed time period.
In some SDKs, the function is called sleep()
, and in others, it's called timer()
.
A Workflow can sleep for months.
Timers are persisted, so even if your Worker or Temporal Service is down when the time period completes, as soon as your Worker and Temporal Service are back up, the sleep()
call will resolve and your code will continue executing.
Sleeping is a resource-light operation: it does not tie up the process, and you can run millions of Timers off a single Worker.
Asynchronous design patterns in TypeScript
The real value of sleep
and condition
is in knowing how to use them to model asynchronous business logic.
Here are some examples we use the most; we welcome more if you can think of them!