Share via


TaskOrchestrator<TInput,TOutput> Class

Definition

Base class for task orchestrator implementations.

public abstract class TaskOrchestrator<TInput,TOutput> : Microsoft.DurableTask.ITaskOrchestrator
type TaskOrchestrator<'Input, 'Output> = class
    interface ITaskOrchestrator
Public MustInherit Class TaskOrchestrator(Of TInput, TOutput)
Implements ITaskOrchestrator

Type Parameters

TInput

The type of the input parameter that this orchestrator accepts.

TOutput

The type of the return value that this orchestrator produces.

Inheritance
TaskOrchestrator<TInput,TOutput>
Implements

Remarks

Task orchestrators describe how actions are executed and the order in which actions are executed. Orchestrators don't call into external services or do complex computation directly. Rather, they delegate these tasks to activities, which perform the actual work.

Orchestrators can be scheduled using an external client (see Microsoft.DurableTask.Client). Orchestrators can also invoke child orchestrators using the CallSubOrchestratorAsync(TaskName, Object, TaskOptions) method. Orchestrators that derive from TaskOrchestrator<TInput,TOutput> can also be invoked using generated extension methods. To participate in code generation, an orchestrator class must be decorated with the DurableTaskAttribute attribute. The source generator will then generate a ScheduleNewMyOrchestratorOrchestratorInstanceAsync() extension method on DurableTaskClient for an orchestrator named "MyOrchestrator". Similarly, a CallMyOrchestratorAsync() extension method will be generated on the TaskOrchestrationContext class for calling "MyOrchestrator" as a sub-orchestration. In all cases, the generated input parameters and return values will be derived from TInput and TOutput respectively.

Orchestrators may be replayed multiple times to rebuild their local state after being reloaded into memory. Orchestrator code must therefore be deterministic to ensure no unexpected side effects from execution replay. To account for this behavior, there are several coding constraints to be aware of:

Orchestrator code is tightly coupled with its execution history so special care must be taken when making changes to orchestrator code. For example, adding or removing activity tasks to an orchestrator's code may cause a mismatch between code and history for in-flight orchestrations. To avoid potential issues related to orchestrator versioning, consider applying the following strategies:

Constructors

TaskOrchestrator<TInput,TOutput>()

Methods

RunAsync(TaskOrchestrationContext, TInput)

Override to implement task orchestrator logic.

Explicit Interface Implementations

ITaskOrchestrator.InputType

Gets the type of the input parameter that this orchestrator accepts.

ITaskOrchestrator.OutputType

Gets the type of the return value that this orchestrator produces.

ITaskOrchestrator.RunAsync(TaskOrchestrationContext, Object)

Invokes the task orchestrator with the specified context and input.

Applies to