Class OrchestrationContext
- Namespace
- DurableTask.Core
- Assembly
- DurableTask.Core.dll
Context for an orchestration containing the instance, replay status, orchestration methods and proxy methods
public abstract class OrchestrationContext
- Inheritance
-
OrchestrationContext
- Inherited Members
Constructors
OrchestrationContext()
protected OrchestrationContext()
Fields
IsOrchestratorThread
Thread-static variable used to signal whether the calling thread is the orchestrator thread. The primary use case is for detecting illegal async usage in orchestration code.
[ThreadStatic]
public static bool IsOrchestratorThread
Field Value
Properties
CurrentUtcDateTime
Replay-safe current UTC datetime
public virtual DateTime CurrentUtcDateTime { get; }
Property Value
ErrorDataConverter
JsonDataConverter for error serialization settings
public JsonDataConverter ErrorDataConverter { get; set; }
Property Value
IsReplaying
True if the code is currently replaying, False if code is truly executing for the first time.
public bool IsReplaying { get; protected set; }
Property Value
MessageDataConverter
JsonDataConverter for message serialization settings
public JsonDataConverter MessageDataConverter { get; set; }
Property Value
OrchestrationInstance
Instance of the currently executing orchestration
public OrchestrationInstance OrchestrationInstance { get; protected set; }
Property Value
Methods
ContinueAsNew(object)
Checkpoint the orchestration instance by completing the current execution in the ContinueAsNew state and creating a new execution of this instance with the specified input parameter. This is useful in unbounded workflows to ensure that the execution history gets cleaned up regularly and does not overflow the preset size limit.
public abstract void ContinueAsNew(object input)
Parameters
input
objectInput to the new execution of this instance. This is the same type as the one used to start the first execution of this orchestration instance.
ContinueAsNew(string, object)
Checkpoint the orchestration instance by completing the current execution in the ContinueAsNew state and creating a new execution of this instance with the specified input parameter. This is useful in unbounded workflows to ensure that the execution history gets cleaned up regularly and does not overflow the preset size limit.
public abstract void ContinueAsNew(string newVersion, object input)
Parameters
newVersion
stringNew version of the orchestration to start
input
objectInput to the new execution of this instance. This is the same type as the one used to start the first execution of this orchestration instance.
CreateClient<T>()
Create a proxy client class to schedule remote TaskActivities via a strongly typed interface.
public virtual T CreateClient<T>() where T : class
Returns
- T
Type Parameters
T
The interface for the proxy client
CreateClient<T>(bool)
Create a proxy client class to schedule remote TaskActivities via a strongly typed interface.
public virtual T CreateClient<T>(bool useFullyQualifiedMethodNames) where T : class
Parameters
useFullyQualifiedMethodNames
boolIf true, the method name translation from the interface contains the interface name, if false then only the method name is used
Returns
- T
Type Parameters
T
The interface for the proxy client
CreateRetryableClient<T>(RetryOptions)
Creates a proxy client with built-in retry logic.
public virtual T CreateRetryableClient<T>(RetryOptions retryOptions) where T : class
Parameters
retryOptions
RetryOptionsRetry policies
Returns
- T
Dynamic proxy that can be used to schedule the remote tasks
Type Parameters
T
Task version of the client interface. This is similar to the actual interface implemented by the client but with the return types always of the form Task<TOriginal> where TOriginal was the return type for the same method in the original interface
CreateRetryableClient<T>(RetryOptions, bool)
Creates a proxy client with built-in retry logic.
public virtual T CreateRetryableClient<T>(RetryOptions retryOptions, bool useFullyQualifiedMethodNames) where T : class
Parameters
retryOptions
RetryOptionsRetry policies
useFullyQualifiedMethodNames
boolIf true, the method name translation from the interface contains the interface name, if false then only the method name is used
Returns
- T
Dynamic proxy that can be used to schedule the remote tasks
Type Parameters
T
Task version of the client interface. This is similar to the actual interface implemented by the client but with the return types always of the form Task<TOriginal> where TOriginal was the return type for the same method in the original interface
CreateSubOrchestrationInstanceWithRetry<T>(string, string, RetryOptions, object)
Create a sub-orchestration of the specified name and version. Also retry on failure as per supplied policy.
public virtual Task<T> CreateSubOrchestrationInstanceWithRetry<T>(string name, string version, RetryOptions retryOptions, object input)
Parameters
name
stringName of the orchestration as specified by the ObjectCreator
version
stringName of the orchestration as specified by the ObjectCreator
retryOptions
RetryOptionsRetry policy
input
objectInput for the TaskOrchestration.RunTask method
Returns
- Task<T>
Task that represents the execution of the specified sub-orchestration
Type Parameters
T
Return Type of the TaskOrchestration.RunTask method
CreateSubOrchestrationInstanceWithRetry<T>(string, string, string, RetryOptions, object)
Create a sub-orchestration of the specified name and version. Also retry on failure as per supplied policy.
public virtual Task<T> CreateSubOrchestrationInstanceWithRetry<T>(string name, string version, string instanceId, RetryOptions retryOptions, object input)
Parameters
name
stringName of the orchestration as specified by the ObjectCreator
version
stringName of the orchestration as specified by the ObjectCreator
instanceId
stringInstance Id of the sub-orchestration
retryOptions
RetryOptionsRetry policy
input
objectInput for the TaskOrchestration.RunTask method
Returns
- Task<T>
Task that represents the execution of the specified sub-orchestration
Type Parameters
T
Return Type of the TaskOrchestration.RunTask method
CreateSubOrchestrationInstanceWithRetry<T>(Type, RetryOptions, object)
Create a sub-orchestration of the specified type. Also retry on failure as per supplied policy.
public virtual Task<T> CreateSubOrchestrationInstanceWithRetry<T>(Type orchestrationType, RetryOptions retryOptions, object input)
Parameters
orchestrationType
TypeType of the TaskOrchestration derived class to instantiate
retryOptions
RetryOptionsRetry policy
input
objectInput for the TaskOrchestration.RunTask method
Returns
- Task<T>
Task that represents the execution of the specified sub-orchestration
Type Parameters
T
Return Type of the TaskOrchestration.RunTask method
CreateSubOrchestrationInstanceWithRetry<T>(Type, string, RetryOptions, object)
Create a sub-orchestration of the specified type. Also retry on failure as per supplied policy.
public virtual Task<T> CreateSubOrchestrationInstanceWithRetry<T>(Type orchestrationType, string instanceId, RetryOptions retryOptions, object input)
Parameters
orchestrationType
TypeType of the TaskOrchestration derived class to instantiate
instanceId
stringInstance Id of the sub-orchestration
retryOptions
RetryOptionsRetry policy
input
objectInput for the TaskOrchestration.RunTask method
Returns
- Task<T>
Task that represents the execution of the specified sub-orchestration
Type Parameters
T
Return Type of the TaskOrchestration.RunTask method
CreateSubOrchestrationInstance<T>(string, string, object)
Create a sub-orchestration of the specified name and version.
public abstract Task<T> CreateSubOrchestrationInstance<T>(string name, string version, object input)
Parameters
name
stringName of the orchestration as specified by the ObjectCreator
version
stringName of the orchestration as specified by the ObjectCreator
input
objectInput for the TaskOrchestration.RunTask method
Returns
- Task<T>
Task that represents the execution of the specified sub-orchestration
Type Parameters
T
Return Type of the TaskOrchestration.RunTask method
CreateSubOrchestrationInstance<T>(string, string, string, object)
Create a sub-orchestration of the specified name and version with the specific instance id
public abstract Task<T> CreateSubOrchestrationInstance<T>(string name, string version, string instanceId, object input)
Parameters
name
stringName of the orchestration as specified by the ObjectCreator
version
stringName of the orchestration as specified by the ObjectCreator
instanceId
stringInstanceId of the sub-orchestration to create
input
objectInput for the TaskOrchestration.RunTask method
Returns
- Task<T>
Task that represents the execution of the specified sub-orchestration
Type Parameters
T
Return Type of the TaskOrchestration.RunTask method
CreateSubOrchestrationInstance<T>(string, string, string, object, IDictionary<string, string>)
Create a sub-orchestration of the specified name and version with the specific instance id
public abstract Task<T> CreateSubOrchestrationInstance<T>(string name, string version, string instanceId, object input, IDictionary<string, string> tags)
Parameters
name
stringName of the orchestration as specified by the ObjectCreator
version
stringName of the orchestration as specified by the ObjectCreator
instanceId
stringInstanceId of the sub-orchestration to create
input
objectInput for the TaskOrchestration.RunTask method
tags
IDictionary<string, string>Dictionary of key/value tags associated with this instance
Returns
- Task<T>
Task that represents the execution of the specified sub-orchestration
Type Parameters
T
Return Type of the TaskOrchestration.RunTask method
CreateSubOrchestrationInstance<T>(Type, object)
Create a sub-orchestration of the specified type.
public virtual Task<T> CreateSubOrchestrationInstance<T>(Type orchestrationType, object input)
Parameters
orchestrationType
TypeType of the TaskOrchestration derived class to instantiate
input
objectInput for the TaskOrchestration.RunTask method
Returns
- Task<T>
Task that represents the execution of the specified sub-orchestration
Type Parameters
T
Return Type of the TaskOrchestration.RunTask method
CreateSubOrchestrationInstance<T>(Type, string, object)
Create a sub-orchestration of the specified type with the specified instance id
public virtual Task<T> CreateSubOrchestrationInstance<T>(Type orchestrationType, string instanceId, object input)
Parameters
orchestrationType
TypeType of the TaskOrchestration derived class to instantiate
instanceId
stringInstanceId of the sub-orchestration to create
input
objectInput for the TaskOrchestration.RunTask method
Returns
- Task<T>
Task that represents the execution of the specified sub-orchestration
Type Parameters
T
Return Type of the TaskOrchestration.RunTask method
CreateTimer<T>(DateTime, T)
Create a timer that will fire at the specified time and hand back the specified state.
public abstract Task<T> CreateTimer<T>(DateTime fireAt, T state)
Parameters
fireAt
DateTimeAbsolute time at which the timer should fire
state
TThe state to be handed back when the timer fires
Returns
- Task<T>
Task that represents the async wait on the timer
Type Parameters
T
Type of state object
CreateTimer<T>(DateTime, T, CancellationToken)
Create a timer that will fire at the specified time and hand back the specified state.
public abstract Task<T> CreateTimer<T>(DateTime fireAt, T state, CancellationToken cancelToken)
Parameters
fireAt
DateTimeAbsolute time at which the timer should fire
state
TThe state to be handed back when the timer fires
cancelToken
CancellationTokenCancellation token
Returns
- Task<T>
Task that represents the async wait on the timer
Type Parameters
T
Type of state object
ScheduleTask<TResult>(string, string, params object[])
Schedule a TaskActivity by name and version.
public abstract Task<TResult> ScheduleTask<TResult>(string name, string version, params object[] parameters)
Parameters
name
stringName of the orchestration as specified by the ObjectCreator
version
stringName of the orchestration as specified by the ObjectCreator
parameters
object[]Parameters for the TaskActivity.Execute method
Returns
- Task<TResult>
Task that represents the execution of the specified TaskActivity
Type Parameters
TResult
Return Type of the TaskActivity.Execute method
ScheduleTask<TResult>(Type, params object[])
Schedule a TaskActivity by type.
public virtual Task<TResult> ScheduleTask<TResult>(Type activityType, params object[] parameters)
Parameters
activityType
TypeType that devices from TaskActivity class
parameters
object[]Parameters for the TaskActivity.Execute method
Returns
- Task<TResult>
Task that represents the execution of the specified TaskActivity
Type Parameters
TResult
Return Type of the TaskActivity.Execute method
ScheduleWithRetry<T>(string, string, RetryOptions, params object[])
Schedule a TaskActivity by name and version. Also retry on failure as per supplied policy.
public virtual Task<T> ScheduleWithRetry<T>(string name, string version, RetryOptions retryOptions, params object[] parameters)
Parameters
name
stringName of the orchestration as specified by the ObjectCreator
version
stringName of the orchestration as specified by the ObjectCreator
retryOptions
RetryOptionsRetry policy
parameters
object[]Parameters for the TaskActivity.Execute method
Returns
- Task<T>
Task that represents the execution of the specified TaskActivity
Type Parameters
T
Return Type of the TaskActivity.Execute method
ScheduleWithRetry<T>(Type, RetryOptions, params object[])
Schedule a TaskActivity by type. Also retry on failure as per supplied policy.
public virtual Task<T> ScheduleWithRetry<T>(Type taskActivityType, RetryOptions retryOptions, params object[] parameters)
Parameters
taskActivityType
TypeType that devices from TaskActivity class
retryOptions
RetryOptionsRetry policy
parameters
object[]Parameters for the TaskActivity.Execute method
Returns
- Task<T>
Task that represents the execution of the specified TaskActivity
Type Parameters
T
Return Type of the TaskActivity.Execute method
SendEvent(OrchestrationInstance, string, object)
Raises an event for the specified orchestration instance, which eventually causes the OnEvent() method in the orchestration to fire.
public abstract void SendEvent(OrchestrationInstance orchestrationInstance, string eventName, object eventData)
Parameters
orchestrationInstance
OrchestrationInstanceInstance in which to raise the event
eventName
stringName of the event
eventData
objectData for the event