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