Interface ITemporalNexusClient
- Namespace
- Temporalio.Nexus
- Assembly
- Temporalio.dll
Nexus-aware client wrapping the Temporal client. Provides methods for starting workflows from within a Nexus operation handler.
public interface ITemporalNexusClient
Remarks
WARNING: Temporal operation handlers are experimental.
Obtained via the FromHandleFactory<TInput, TResult>(Func<TemporalOperationStartContext, ITemporalNexusClient, TInput, Task<TemporalOperationResult<TResult>>>) start function parameter.
Example usage — starting a workflow from an operation handler:
await client.StartWorkflowAsync<MyWorkflow, MyResult>(
wf => wf.RunAsync(input),
new(id: "my-workflow-id", taskQueue: "my-task-queue"));
To perform a synchronous operation (e.g., sending a signal), use the underlying TemporalClient and return a sync result:
await client.TemporalClient
.GetWorkflowHandle($"order-{input.OrderId}")
.SignalAsync("requestCancellation", new[] { input });
return TemporalOperationResult<NoValue>.SyncResult(default);
Properties
TemporalClient
Gets the underlying Temporal client for advanced use cases such as sending signals or queries.
ITemporalClient TemporalClient { get; }
Property Value
Methods
StartActivityAsync(Expression<Func<Task>>, StartActivityOptions)
Schedule a standalone activity via a lambda invoking the activity method with no return value. Always returns an async result with an activity-execution operation token.
Task<TemporalOperationResult<NoValue>> StartActivityAsync(Expression<Func<Task>> activityCall, StartActivityOptions options)
Parameters
activityCallExpression<Func<Task>>Invocation of activity method with no result.
optionsStartActivityOptionsActivity start options. Id is required and should be derived deterministically from the operation input so retries of the Nexus start request are idempotent. At least one of ScheduleToCloseTimeout or StartToCloseTimeout is also required. TaskQueue defaults to the operation's task queue when omitted.
Returns
- Task<TemporalOperationResult<NoValue>>
An async operation result containing the activity-execution token.
StartActivityAsync<TResult>(Expression<Func<Task<TResult>>>, StartActivityOptions)
Schedule a standalone activity via a lambda invoking the activity method. Always returns an async result with an activity-execution operation token.
Task<TemporalOperationResult<TResult>> StartActivityAsync<TResult>(Expression<Func<Task<TResult>>> activityCall, StartActivityOptions options)
Parameters
activityCallExpression<Func<Task<TResult>>>Invocation of activity method with a result.
optionsStartActivityOptionsActivity start options. Id is required and should be derived deterministically from the operation input so retries of the Nexus start request are idempotent. At least one of ScheduleToCloseTimeout or StartToCloseTimeout is also required. TaskQueue defaults to the operation's task queue when omitted.
Returns
- Task<TemporalOperationResult<TResult>>
An async operation result containing the activity-execution token.
Type Parameters
TResultActivity result type.
StartActivityAsync<TResult>(string, IReadOnlyCollection<object?>, StartActivityOptions)
Schedule a standalone activity by name. Always returns an async result with an activity-execution operation token.
Task<TemporalOperationResult<TResult>> StartActivityAsync<TResult>(string activity, IReadOnlyCollection<object?> args, StartActivityOptions options)
Parameters
activitystringActivity type name.
argsIReadOnlyCollection<object>Arguments for the activity.
optionsStartActivityOptionsActivity start options. Id is required and should be derived deterministically from the operation input so retries of the Nexus start request are idempotent. At least one of ScheduleToCloseTimeout or StartToCloseTimeout is also required. TaskQueue defaults to the operation's task queue when omitted.
Returns
- Task<TemporalOperationResult<TResult>>
An async operation result containing the activity-execution token.
Type Parameters
TResultActivity result type.
StartWorkflowAsync<TWorkflow>(Expression<Func<TWorkflow, Task>>, WorkflowOptions)
Start a workflow via a lambda invoking the run method with no return value. Always returns an async result with a workflow-run operation token.
Task<TemporalOperationResult<NoValue>> StartWorkflowAsync<TWorkflow>(Expression<Func<TWorkflow, Task>> workflowRunCall, WorkflowOptions options)
Parameters
workflowRunCallExpression<Func<TWorkflow, Task>>Invocation of workflow run method with no result.
optionsWorkflowOptionsStart workflow options. ID is required; TaskQueue defaults to the operation's task queue when omitted.
Returns
- Task<TemporalOperationResult<NoValue>>
An async operation result containing the workflow-run token.
Type Parameters
TWorkflowWorkflow class type.
StartWorkflowAsync<TResult>(string, IReadOnlyCollection<object?>, WorkflowOptions)
Start a workflow by name. Always returns an async result with a workflow-run operation token.
Task<TemporalOperationResult<TResult>> StartWorkflowAsync<TResult>(string workflow, IReadOnlyCollection<object?> args, WorkflowOptions options)
Parameters
workflowstringWorkflow type name.
argsIReadOnlyCollection<object>Arguments for the workflow.
optionsWorkflowOptionsStart workflow options. ID is required; TaskQueue defaults to the operation's task queue when omitted.
Returns
- Task<TemporalOperationResult<TResult>>
An async operation result containing the workflow-run token.
Type Parameters
TResultWorkflow result type.
StartWorkflowAsync<TWorkflow, TResult>(Expression<Func<TWorkflow, Task<TResult>>>, WorkflowOptions)
Start a workflow via a lambda invoking the run method. Always returns an async result with a workflow-run operation token.
Task<TemporalOperationResult<TResult>> StartWorkflowAsync<TWorkflow, TResult>(Expression<Func<TWorkflow, Task<TResult>>> workflowRunCall, WorkflowOptions options)
Parameters
workflowRunCallExpression<Func<TWorkflow, Task<TResult>>>Invocation of workflow run method with a result.
optionsWorkflowOptionsStart workflow options. ID is required; TaskQueue defaults to the operation's task queue when omitted.
Returns
- Task<TemporalOperationResult<TResult>>
An async operation result containing the workflow-run token.
Type Parameters
TWorkflowWorkflow class type.
TResultWorkflow result type.
StartWorkflowUpdateAsync<TWorkflow>(string, Expression<Func<TWorkflow, Task>>, WorkflowUpdateStartOptions, string?)
Start a workflow update with no result via a lambda invoking the update method, backing this Nexus operation with the update.
Task<TemporalOperationResult<NoValue>> StartWorkflowUpdateAsync<TWorkflow>(string workflowId, Expression<Func<TWorkflow, Task>> updateCall, WorkflowUpdateStartOptions options, string? runId = null)
Parameters
workflowIdstringTarget workflow ID.
updateCallExpression<Func<TWorkflow, Task>>Invocation of the workflow update method with no result.
optionsWorkflowUpdateStartOptionsUpdate start options.
WaitForStagemust be Accepted. If the update ID is unset, the Nexus request ID is used.runIdstringTarget workflow run ID, or null for the latest run.
Returns
- Task<TemporalOperationResult<NoValue>>
An operation result for the update.
Type Parameters
TWorkflowWorkflow class type.
Remarks
Only Accepted is supported for
WaitForStage. The operation requires a callback URL to be present.
StartWorkflowUpdateAsync<TResult>(string, string, IReadOnlyCollection<object?>, WorkflowUpdateStartOptions, string?)
Start a workflow update by name, backing this Nexus operation with the update.
Task<TemporalOperationResult<TResult>> StartWorkflowUpdateAsync<TResult>(string workflowId, string update, IReadOnlyCollection<object?> args, WorkflowUpdateStartOptions options, string? runId = null)
Parameters
workflowIdstringTarget workflow ID.
updatestringUpdate name.
argsIReadOnlyCollection<object>Update arguments.
optionsWorkflowUpdateStartOptionsUpdate start options.
WaitForStagemust be Accepted. If the update ID is unset, the Nexus request ID is used.runIdstringTarget workflow run ID, or null for the latest run.
Returns
- Task<TemporalOperationResult<TResult>>
An operation result for the update.
Type Parameters
TResultUpdate result type.
Remarks
Only Accepted is supported for
WaitForStage. The operation requires a callback URL to be present.
Returns an async result carrying an update-workflow token, unless the update has already completed (e.g. a retried request with the same update ID), in which case a sync result is returned; an update that completed with an error surfaces as a failed operation.
StartWorkflowUpdateAsync<TWorkflow, TResult>(string, Expression<Func<TWorkflow, Task<TResult>>>, WorkflowUpdateStartOptions, string?)
Start a workflow update via a lambda invoking the update method, backing this Nexus operation with the update.
Task<TemporalOperationResult<TResult>> StartWorkflowUpdateAsync<TWorkflow, TResult>(string workflowId, Expression<Func<TWorkflow, Task<TResult>>> updateCall, WorkflowUpdateStartOptions options, string? runId = null)
Parameters
workflowIdstringTarget workflow ID.
updateCallExpression<Func<TWorkflow, Task<TResult>>>Invocation of the workflow update method with a result.
optionsWorkflowUpdateStartOptionsUpdate start options.
WaitForStagemust be Accepted. If the update ID is unset, the Nexus request ID is used.runIdstringTarget workflow run ID, or null for the latest run.
Returns
- Task<TemporalOperationResult<TResult>>
An operation result for the update.
Type Parameters
TWorkflowWorkflow class type.
TResultUpdate result type.
Remarks
Only Accepted is supported for
WaitForStage.
Returns an async result carrying an update-workflow token, unless the update has already completed (e.g. a retried request with the same update ID), in which case a sync result is returned; an update that completed with an error surfaces as a failed operation.