Skip to content

DurableTaskGrainExtensions Methods

Provides operations for observing and signaling existing durable tasks on grain references.

GetDurableTask(IAddressable, TaskId)

staticextension
View source
public static DurableTaskReference<TResult> GetDurableTask<TResult>(this IAddressable target, TaskId taskId)
Gets a reference to the existing durable task taskId on target, without scheduling it.

Parameters

targetIAddressable
The grain which owns the durable task, which can be the calling grain.
taskIdTaskId
The identifier of a task which a client, a grain, or a durable execution started.

Returns

A reference which a durable execution awaits, schedules, or passes to combinators to subscribe to the task's result, and which other code awaits, polls, cancels, or aborts.

Exceptions

System.ArgumentNullException
target is null.
System.ArgumentException
taskId is empty.

GetDurableTask(IAddressable, string)

staticextension
View source
public static DurableTaskReference<TResult> GetDurableTask<TResult>(this IAddressable target, string rootId)
Gets a reference to the existing root durable task rootId on target, without scheduling it.

Parameters

targetIAddressable
The grain which owns the durable task, which can be the calling grain.
rootIdstring
The root ID of a task which a client, a grain, or a durable execution started.

Returns

A reference which behaves as DurableTaskGrainExtensions describes.

Exceptions

System.ArgumentNullException
target is null.
System.ArgumentException
rootId is empty or whitespace.

SignalDurableTaskAsync(IAddressable, TaskId, DurableSignal<T>, T, CancellationToken)

staticextension
View source
public static ValueTask SignalDurableTaskAsync<T>(this IAddressable target, TaskId taskId, DurableSignal<T> signal, T value, CancellationToken cancellationToken = default(CancellationToken))
Delivers signal with value to the invoked task taskId on target.

Parameters

targetIAddressable
The grain which owns the task.
taskIdTaskId
The identifier of a task which a client or another grain invoked on target.
signalDurableSignal<T>
The signal descriptor which the task's waits share.
valueT
The signal's value.
cancellationTokenCancellationToken
A token which abandons the send.

Returns

An operation which completes once the send is durable.

Exceptions

System.ArgumentNullException
target or signal is null.
System.ArgumentException
taskId is empty.
Orleans.Durable.Tasks.DurableTaskNotFoundException
Outside a durable execution, the target retains no invoked task taskId.
System.InvalidOperationException
Outside a durable execution, the task holds a different value for the signal, or it is terminal and holds no value for the signal.

SignalDurableTaskAsync(IAddressable, string, DurableSignal<T>, T, CancellationToken)

staticextension
View source
public static ValueTask SignalDurableTaskAsync<T>(this IAddressable target, string rootId, DurableSignal<T> signal, T value, CancellationToken cancellationToken = default(CancellationToken))
Delivers signal with value to the root task rootId on target.

Parameters

targetIAddressable
The grain which owns the task.
rootIdstring
The root ID of a task which a client, a grain, or a durable execution started.
signalDurableSignal<T>
The signal descriptor which the task's waits share.
valueT
The signal's value.
cancellationTokenCancellationToken
A token which abandons the send.

Returns

A task which completes as DurableTaskGrainExtensions describes.

TryGetTarget(DurableTask, GrainId)

staticextension
View source
public static bool TryGetTarget(this DurableTask task, out GrainId target)
Gets the grain which a durable grain call targets, before the call is scheduled.

Parameters

taskDurableTask
The durable task definition.
targetGrainId
The grain which the call targets, when this method returns true; otherwise default.

Returns

true when task is a call to a grain's DurableTask-returning method, made through a grain reference and not yet scheduled; otherwise false, such as for a local definition like DurableTask or a reference to an existing task.

Exceptions

System.ArgumentNullException
task is null.

TrySignalDurableTaskAsync(IAddressable, TaskId, DurableSignal<T>, T, CancellationToken)

staticextension
View source
public static ValueTask<DurableSignalResult> TrySignalDurableTaskAsync<T>(this IAddressable target, TaskId taskId, DurableSignal<T> signal, T value, CancellationToken cancellationToken = default(CancellationToken))
Delivers signal with value to the invoked task taskId on target, and returns how the task handled it.

Parameters

targetIAddressable
The grain which owns the task.
taskIdTaskId
The identifier of a task which a client or another grain invoked on target.
signalDurableSignal<T>
The signal descriptor which the task's waits share.
valueT
The signal's value.
cancellationTokenCancellationToken
A token which abandons the send.

Returns

DurableSignalResult or DurableSignalResult once the task durably holds the value, or the reason the task rejected it, which changes nothing.

Exceptions

System.ArgumentNullException
target or signal is null.
System.ArgumentException
taskId is empty.
System.InvalidOperationException
The caller is a durable execution.

TrySignalDurableTaskAsync(IAddressable, string, DurableSignal<T>, T, CancellationToken)

staticextension
View source
public static ValueTask<DurableSignalResult> TrySignalDurableTaskAsync<T>(this IAddressable target, string rootId, DurableSignal<T> signal, T value, CancellationToken cancellationToken = default(CancellationToken))
Delivers signal with value to the root task rootId on target, and returns how the task handled it.

Parameters

targetIAddressable
The grain which owns the task.
rootIdstring
The root ID of a task which a client, a grain, or a durable execution started.
signalDurableSignal<T>
The signal descriptor which the task's waits share.
valueT
The signal's value.
cancellationTokenCancellationToken
A token which abandons the send.

Returns

The task's handling of the signal, as DurableTaskGrainExtensions returns.