Table of Contents

Class TemporalOperationAttribute

Namespace
Temporalio.Nexus
Assembly
Temporalio.dll

Marks a method on a class with a NexusRpc.Handlers.NexusServiceHandlerAttribute as a Temporal-backed Nexus operation start handler. The method is invoked directly on every operation start rather than acting as an operation handler factory.

[AttributeUsage(AttributeTargets.Method, Inherited = false)]
public sealed class TemporalOperationAttribute : Attribute
Inheritance
TemporalOperationAttribute
Inherited Members

Remarks

WARNING: Nexus support is experimental.

The method must be an instance method with signature Task<TemporalOperationResult<TResult>> Method(TemporalOperationStartContext ctx, ITemporalNexusClient client[, TInput input]). The third input parameter is omitted for operations with no input (i.e., NexusRpc.Handlers.NoValue input). Cancel calls are handled by the built-in TemporalOperationHandler<TInput, TResult> logic (typically canceling the underlying workflow).

This attribute is mutually exclusive with NexusRpc.Handlers.NexusOperationHandlerAttribute on the same method. The operation this method handles is matched by C# method name to the corresponding NexusRpc.NexusOperationAttribute method on the service interface. An exact match takes precedence. If no exact match exists and the handler method name ends with Async, the SDK removes this suffix before matching again. This does not change the operation's wire name.

Example:

[NexusServiceHandler(typeof(ITransferService))]
public class TransferServiceImpl
{
    [TemporalOperation]
    public Task<TemporalOperationResult<TransferResult>> DoSomethingAsync(
        TemporalOperationStartContext ctx, ITemporalNexusClient client, TransferInput input) =>
        client.StartWorkflowAsync(
            (TransferWorkflow wf) => wf.RunAsync(input),
            new() { Id = $"transfer-{input.TransferId}" });
}