Table of Contents

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

ITemporalClient

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

activityCall Expression<Func<Task>>

Invocation of activity method with no result.

options StartActivityOptions

Activity 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

activityCall Expression<Func<Task<TResult>>>

Invocation of activity method with a result.

options StartActivityOptions

Activity 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

TResult

Activity 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

activity string

Activity type name.

args IReadOnlyCollection<object>

Arguments for the activity.

options StartActivityOptions

Activity 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

TResult

Activity 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

workflowRunCall Expression<Func<TWorkflow, Task>>

Invocation of workflow run method with no result.

options WorkflowOptions

Start 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

TWorkflow

Workflow 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

workflow string

Workflow type name.

args IReadOnlyCollection<object>

Arguments for the workflow.

options WorkflowOptions

Start 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

TResult

Workflow 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

workflowRunCall Expression<Func<TWorkflow, Task<TResult>>>

Invocation of workflow run method with a result.

options WorkflowOptions

Start 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

TWorkflow

Workflow class type.

TResult

Workflow 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

workflowId string

Target workflow ID.

updateCall Expression<Func<TWorkflow, Task>>

Invocation of the workflow update method with no result.

options WorkflowUpdateStartOptions

Update start options. WaitForStage must be Accepted. If the update ID is unset, the Nexus request ID is used.

runId string

Target workflow run ID, or null for the latest run.

Returns

Task<TemporalOperationResult<NoValue>>

An operation result for the update.

Type Parameters

TWorkflow

Workflow 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

workflowId string

Target workflow ID.

update string

Update name.

args IReadOnlyCollection<object>

Update arguments.

options WorkflowUpdateStartOptions

Update start options. WaitForStage must be Accepted. If the update ID is unset, the Nexus request ID is used.

runId string

Target workflow run ID, or null for the latest run.

Returns

Task<TemporalOperationResult<TResult>>

An operation result for the update.

Type Parameters

TResult

Update 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

workflowId string

Target workflow ID.

updateCall Expression<Func<TWorkflow, Task<TResult>>>

Invocation of the workflow update method with a result.

options WorkflowUpdateStartOptions

Update start options. WaitForStage must be Accepted. If the update ID is unset, the Nexus request ID is used.

runId string

Target workflow run ID, or null for the latest run.

Returns

Task<TemporalOperationResult<TResult>>

An operation result for the update.

Type Parameters

TWorkflow

Workflow class type.

TResult

Update 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.