Class WorkflowHandle
- Namespace
- Temporalio.Client
- Assembly
- Temporalio.dll
Workflow handle to perform actions on an individual workflow.
public record WorkflowHandle : IEquatable<WorkflowHandle>
- Inheritance
-
WorkflowHandle
- Implements
- Derived
- Inherited Members
Constructors
WorkflowHandle(ITemporalClient, string, string?, string?, string?)
Workflow handle to perform actions on an individual workflow.
public WorkflowHandle(ITemporalClient Client, string Id, string? RunId = null, string? ResultRunId = null, string? FirstExecutionRunId = null)
Parameters
ClientITemporalClientClient used for workflow handle calls.
IdstringWorkflow ID.
RunIdstringRun ID used for signals, queries, and updates if present to ensure a very specific run to call. This is only set when getting a workflow handle, not when starting a workflow.
ResultRunIdstringRun ID used for get result calls to ensure getting a result starting from this run. This is set the same as a run ID when getting a workflow handle. When starting a workflow, this is set as the resulting run ID.
FirstExecutionRunIdstringRun ID used for cancellation and termination to ensure they happen on a workflow starting with this run ID. This can be set when getting a workflow handle. When starting a workflow, this is set as the resulting run ID if no start signal was provided.
Properties
Client
Client used for workflow handle calls.
public ITemporalClient Client { get; init; }
Property Value
FirstExecutionRunId
Run ID used for cancellation and termination to ensure they happen on a workflow starting with this run ID. This can be set when getting a workflow handle. When starting a workflow, this is set as the resulting run ID if no start signal was provided.
public string? FirstExecutionRunId { get; init; }
Property Value
Id
Workflow ID.
public string Id { get; init; }
Property Value
ResultRunId
Run ID used for get result calls to ensure getting a result starting from this run. This is set the same as a run ID when getting a workflow handle. When starting a workflow, this is set as the resulting run ID.
public string? ResultRunId { get; init; }
Property Value
RunId
Run ID used for signals, queries, and updates if present to ensure a very specific run to call. This is only set when getting a workflow handle, not when starting a workflow.
public string? RunId { get; init; }
Property Value
Methods
CancelAsync(WorkflowCancelOptions?)
Request cancellation of this workflow.
public virtual Task CancelAsync(WorkflowCancelOptions? options = null)
Parameters
optionsWorkflowCancelOptionsCancellation options.
Returns
- Task
Cancel accepted task.
Exceptions
- RpcException
Server-side error.
DescribeAsync(WorkflowDescribeOptions?)
Get the current description of this workflow.
public virtual Task<WorkflowExecutionDescription> DescribeAsync(WorkflowDescribeOptions? options = null)
Parameters
optionsWorkflowDescribeOptionsExtra options.
Returns
- Task<WorkflowExecutionDescription>
Description for the workflow.
ExecuteUpdateAsync(string, IReadOnlyCollection<object?>, WorkflowUpdateOptions?)
Start an update and wait for it to complete. This is a shortcut for StartUpdateAsync(string, IReadOnlyCollection<object?>, WorkflowUpdateStartOptions) + GetResultAsync(RpcOptions?).
public Task ExecuteUpdateAsync(string update, IReadOnlyCollection<object?> args, WorkflowUpdateOptions? options = null)
Parameters
updatestringUpdate name.
argsIReadOnlyCollection<object>Update args.
optionsWorkflowUpdateOptionsExtra options.
Returns
- Task
Completed update task.
ExecuteUpdateAsync<TWorkflow>(Expression<Func<TWorkflow, Task>>, WorkflowUpdateOptions?)
Start an update and wait for it to complete. This is a shortcut for StartUpdateAsync<TWorkflow>(Expression<Func<TWorkflow, Task>>, WorkflowUpdateStartOptions) + GetResultAsync(RpcOptions?).
public Task ExecuteUpdateAsync<TWorkflow>(Expression<Func<TWorkflow, Task>> updateCall, WorkflowUpdateOptions? options = null)
Parameters
updateCallExpression<Func<TWorkflow, Task>>Invocation of workflow update method.
optionsWorkflowUpdateOptionsExtra options.
Returns
- Task
Completed update task.
Type Parameters
TWorkflowWorkflow class type.
ExecuteUpdateAsync<TUpdateResult>(string, IReadOnlyCollection<object?>, WorkflowUpdateOptions?)
Start an update and wait for it to complete. This is a shortcut for StartUpdateAsync<TUpdateResult>(string, IReadOnlyCollection<object?>, WorkflowUpdateStartOptions) + GetResultAsync(RpcOptions?).
public Task<TUpdateResult> ExecuteUpdateAsync<TUpdateResult>(string update, IReadOnlyCollection<object?> args, WorkflowUpdateOptions? options = null)
Parameters
updatestringUpdate name.
argsIReadOnlyCollection<object>Update args.
optionsWorkflowUpdateOptionsExtra options.
Returns
- Task<TUpdateResult>
Completed update task.
Type Parameters
TUpdateResultUpdate result type.
ExecuteUpdateAsync<TWorkflow, TUpdateResult>(Expression<Func<TWorkflow, Task<TUpdateResult>>>, WorkflowUpdateOptions?)
Start an update and wait for it to complete. This is a shortcut for StartUpdateAsync<TWorkflow, TUpdateResult>(Expression<Func<TWorkflow, Task<TUpdateResult>>>, WorkflowUpdateStartOptions) + GetResultAsync(RpcOptions?).
public Task<TUpdateResult> ExecuteUpdateAsync<TWorkflow, TUpdateResult>(Expression<Func<TWorkflow, Task<TUpdateResult>>> updateCall, WorkflowUpdateOptions? options = null)
Parameters
updateCallExpression<Func<TWorkflow, Task<TUpdateResult>>>Invocation of workflow update method.
optionsWorkflowUpdateOptionsExtra options.
Returns
- Task<TUpdateResult>
Completed update task.
Type Parameters
TWorkflowWorkflow class type.
TUpdateResultUpdate result type.
FetchHistoryAsync(WorkflowHistoryEventFetchOptions?)
Fetch history for the workflow.
public virtual Task<WorkflowHistory> FetchHistoryAsync(WorkflowHistoryEventFetchOptions? options = null)
Parameters
optionsWorkflowHistoryEventFetchOptionsOptions for history fetching.
Returns
- Task<WorkflowHistory>
Fetched history.
FetchHistoryEventsAsync(WorkflowHistoryEventFetchOptions?)
Asynchronously iterate over history events.
public virtual IAsyncEnumerable<HistoryEvent> FetchHistoryEventsAsync(WorkflowHistoryEventFetchOptions? options = null)
Parameters
optionsWorkflowHistoryEventFetchOptionsHistory event fetch options.
Returns
- IAsyncEnumerable<HistoryEvent>
Async enumerable to iterate events for.
GetResultAsync(bool, RpcOptions?)
Get the result of a workflow disregarding its return (or not having a return type).
public Task GetResultAsync(bool followRuns = true, RpcOptions? rpcOptions = null)
Parameters
followRunsboolWhether to follow runs until the latest workflow is reached.
rpcOptionsRpcOptionsRPC options.
Returns
- Task
Untyped task for waiting on result.
Exceptions
- WorkflowFailedException
Exception thrown for unsuccessful workflow result. The cause can be CanceledFailureException, TerminatedFailureException, TimeoutFailureException, or any exception deserialized that was thrown in the workflow (usually an ApplicationFailureException).
- RpcException
Server-side error.
GetResultAsync<TResult>(bool, RpcOptions?)
Get the result of a workflow, deserializing into the given return type.
public virtual Task<TResult> GetResultAsync<TResult>(bool followRuns = true, RpcOptions? rpcOptions = null)
Parameters
followRunsboolWhether to follow runs until the latest workflow is reached.
rpcOptionsRpcOptionsRPC options.
Returns
- Task<TResult>
Result of the workflow.
Type Parameters
TResultReturn type to deserialize result into.
Exceptions
- WorkflowFailedException
Exception thrown for unsuccessful workflow result. The cause can be CanceledFailureException, TerminatedFailureException, TimeoutFailureException, or any exception deserialized that was thrown in the workflow (usually an ApplicationFailureException).
- RpcException
Server-side error.
GetUpdateHandle(string)
Get a workflow update handle for the given update ID on this workflow.
public WorkflowUpdateHandle GetUpdateHandle(string id)
Parameters
idstringID of the update.
Returns
- WorkflowUpdateHandle
Workflow update handle.
GetUpdateHandle<TUpdateResult>(string)
Get a workflow update handle for the given update ID on this workflow.
public WorkflowUpdateHandle<TUpdateResult> GetUpdateHandle<TUpdateResult>(string id)
Parameters
idstringID of the update.
Returns
- WorkflowUpdateHandle<TUpdateResult>
Workflow update handle.
Type Parameters
TUpdateResultUpdate result type.
QueryAsync<TQueryResult>(string, IReadOnlyCollection<object?>, WorkflowQueryOptions?)
Query a workflow with the given WorkflowQuery attributed method.
public virtual Task<TQueryResult> QueryAsync<TQueryResult>(string query, IReadOnlyCollection<object?> args, WorkflowQueryOptions? options = null)
Parameters
querystringWorkflow query method.
argsIReadOnlyCollection<object>Query arguments.
optionsWorkflowQueryOptionsExtra options.
Returns
- Task<TQueryResult>
Query result.
Type Parameters
TQueryResultQuery result type.
Exceptions
- WorkflowQueryFailedException
Query failed on worker.
- WorkflowQueryRejectedException
Query rejected by server based on rejection condition.
- RpcException
Server-side error.
QueryAsync<TWorkflow, TQueryResult>(Expression<Func<TWorkflow, TQueryResult>>, WorkflowQueryOptions?)
Query a workflow via a lambda that calls a WorkflowQuery attributed method or accesses a WorkflowQuery attributed property.
public Task<TQueryResult> QueryAsync<TWorkflow, TQueryResult>(Expression<Func<TWorkflow, TQueryResult>> queryCall, WorkflowQueryOptions? options = null)
Parameters
queryCallExpression<Func<TWorkflow, TQueryResult>>Invocation of a workflow query method or access of workflow query property.
optionsWorkflowQueryOptionsExtra options.
Returns
- Task<TQueryResult>
Query result.
Type Parameters
TWorkflowWorkflow class type.
TQueryResultQuery result type.
Exceptions
- WorkflowQueryFailedException
Query failed on worker.
- WorkflowQueryRejectedException
Query rejected by server based on rejection condition.
- RpcException
Server-side error.
SignalAsync(string, IReadOnlyCollection<object?>, WorkflowSignalOptions?)
Signal a workflow with the given signal name and args.
public virtual Task SignalAsync(string signal, IReadOnlyCollection<object?> args, WorkflowSignalOptions? options = null)
Parameters
signalstringSignal name.
argsIReadOnlyCollection<object>Signal args.
optionsWorkflowSignalOptionsExtra options.
Returns
- Task
Signal completion task. Means signal was accepted, but may not have been processed by the workflow yet.
Exceptions
- RpcException
Server-side error.
SignalAsync<TWorkflow>(Expression<Func<TWorkflow, Task>>, WorkflowSignalOptions?)
Signal a workflow via a lambda call to a WorkflowSignal attributed method.
public Task SignalAsync<TWorkflow>(Expression<Func<TWorkflow, Task>> signalCall, WorkflowSignalOptions? options = null)
Parameters
signalCallExpression<Func<TWorkflow, Task>>Invocation of a workflow signal method.
optionsWorkflowSignalOptionsExtra options.
Returns
- Task
Signal completion task. Means signal was accepted, but may not have been processed by the workflow yet.
Type Parameters
TWorkflowWorkflow class type.
Exceptions
- RpcException
Server-side error.
StartUpdateAsync(string, IReadOnlyCollection<object?>, WorkflowUpdateStartOptions)
Start a workflow update using its name.
public Task<WorkflowUpdateHandle> StartUpdateAsync(string update, IReadOnlyCollection<object?> args, WorkflowUpdateStartOptions options)
Parameters
updatestringName of the update.
argsIReadOnlyCollection<object>Arguments for the update.
optionsWorkflowUpdateStartOptionsUpdate options. Currently
WaitForStageis required.
Returns
- Task<WorkflowUpdateHandle>
Workflow update handle.
StartUpdateAsync<TWorkflow>(Expression<Func<TWorkflow, Task>>, WorkflowUpdateStartOptions)
Start a workflow update via a call to a WorkflowUpdate attributed method.
public Task<WorkflowUpdateHandle> StartUpdateAsync<TWorkflow>(Expression<Func<TWorkflow, Task>> updateCall, WorkflowUpdateStartOptions options)
Parameters
updateCallExpression<Func<TWorkflow, Task>>Invocation of workflow update method.
optionsWorkflowUpdateStartOptionsUpdate options. Currently
WaitForStageis required.
Returns
- Task<WorkflowUpdateHandle>
Workflow update handle.
Type Parameters
TWorkflowWorkflow class type.
StartUpdateAsync<TUpdateResult>(string, IReadOnlyCollection<object?>, WorkflowUpdateStartOptions)
Start a workflow update using its name.
public virtual Task<WorkflowUpdateHandle<TUpdateResult>> StartUpdateAsync<TUpdateResult>(string update, IReadOnlyCollection<object?> args, WorkflowUpdateStartOptions options)
Parameters
updatestringName of the update.
argsIReadOnlyCollection<object>Arguments for the update.
optionsWorkflowUpdateStartOptionsUpdate options. Currently
WaitForStageis required.
Returns
- Task<WorkflowUpdateHandle<TUpdateResult>>
Workflow update handle.
Type Parameters
TUpdateResultUpdate result type.
StartUpdateAsync<TWorkflow, TUpdateResult>(Expression<Func<TWorkflow, Task<TUpdateResult>>>, WorkflowUpdateStartOptions)
Start a workflow update via a call to a WorkflowUpdate attributed method.
public Task<WorkflowUpdateHandle<TUpdateResult>> StartUpdateAsync<TWorkflow, TUpdateResult>(Expression<Func<TWorkflow, Task<TUpdateResult>>> updateCall, WorkflowUpdateStartOptions options)
Parameters
updateCallExpression<Func<TWorkflow, Task<TUpdateResult>>>Invocation of workflow update method.
optionsWorkflowUpdateStartOptionsUpdate options. Currently
WaitForStageis required.
Returns
- Task<WorkflowUpdateHandle<TUpdateResult>>
Workflow update handle.
Type Parameters
TWorkflowWorkflow class type.
TUpdateResultUpdate result type.
TerminateAsync(string?, WorkflowTerminateOptions?)
Terminate this workflow.
public virtual Task TerminateAsync(string? reason = null, WorkflowTerminateOptions? options = null)
Parameters
reasonstringTermination reason.
optionsWorkflowTerminateOptionsTermination options.
Returns
- Task
Terminate completed task.
Exceptions
- RpcException
Server-side error.