TimerTask interface
Returned from DurableClient.createTimer(Date) if the call is
not yield
-ed. Represents a pending timer. See documentation on Task
for more information.
All pending timers must be completed or canceled for an orchestration to complete.
Example
Cancel a timer
// calculate expiration date
const timeoutTask = context.df.createTimer(expirationDate);
// do some work
if (!timeoutTask.isCompleted) {
// An orchestration won't get marked as completed until all its scheduled
// tasks have returned, or been cancelled. Therefore, it is important
// to cancel timers when they're no longer needed
timeoutTask.cancel();
}
Example
Create a timeout
const now = Date.now();
const expiration = new Date(now.valueOf()).setMinutes(now.getMinutes() + 30);
const timeoutTask = context.df.createTimer(expirationDate);
const otherTask = context.df.callActivity("DoWork");
const winner = yield context.df.Task.any([timeoutTask, otherTask]);
if (winner === otherTask) {
// do some more work
}
if (!timeoutTask.isCompleted) {
// An orchestration won't get marked as completed until all its scheduled
// tasks have returned, or been cancelled. Therefore, it is important
// to cancel timers when they're no longer needed
timeoutTask.cancel();
}
- Extends
Properties
cancel | Indicates the timer should be canceled. This request will execute on the
next |
is |
Inherited Properties
is |
Whether the task has completed. Note that completion is not equivalent to success. |
is |
Whether the task faulted in some way due to error. |
result | The result of the task, if completed. Otherwise |
Property Details
cancel
Indicates the timer should be canceled. This request will execute on the
next yield
or return
statement.
cancel: () => void
Property Value
() => void
isCanceled
isCanceled: boolean
Property Value
boolean
Whether or not the timer has been canceled.
Inherited Property Details
isCompleted
Whether the task has completed. Note that completion is not equivalent to success.
isCompleted: boolean
Property Value
boolean
Inherited From Task.isCompleted
isFaulted
Whether the task faulted in some way due to error.
isFaulted: boolean
Property Value
boolean
Inherited From Task.isFaulted
result
The result of the task, if completed. Otherwise undefined
.
result?: unknown
Property Value
unknown
Inherited From Task.result