diff --git a/src/DurableTask.Core/Entities/EntityExecutionOptions.cs b/src/DurableTask.Core/Entities/EntityExecutionOptions.cs deleted file mode 100644 index f6f04e800..000000000 --- a/src/DurableTask.Core/Entities/EntityExecutionOptions.cs +++ /dev/null @@ -1,55 +0,0 @@ -// ---------------------------------------------------------------------------------- -// Copyright Microsoft Corporation -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// ---------------------------------------------------------------------------------- -#nullable enable -namespace DurableTask.Core.Entities -{ - using DurableTask.Core.Serializing; - - /// - /// Options that are used for configuring how a TaskEntity executes entity operations. - /// - public class EntityExecutionOptions - { - /// - /// The data converter used for converting inputs and outputs for operations. - /// - public DataConverter MessageDataConverter { get; set; } = JsonDataConverter.Default; - - /// - /// The data converter used for the entity state. - /// - public DataConverter StateDataConverter { get; set; } = JsonDataConverter.Default; - - /// - /// The data converter used for exceptions. - /// - public DataConverter ErrorDataConverter { get; set; } = JsonDataConverter.Default; - - /// - /// If true, all effects of an entity operation (all state changes and all actions) are rolled back - /// if the entity operation completes with an exception. - /// Implementations may override this setting. - /// - public bool RollbackOnExceptions { get; set; } = true; - - /// - /// Information about backend entity support. - /// - internal EntityBackendProperties? EntityBackendProperties { get; set; } - - /// - /// The mode that is used for propagating errors, as specified in the . - /// - internal ErrorPropagationMode ErrorPropagationMode { get; set; } - } -} \ No newline at end of file diff --git a/src/DurableTask.Core/Entities/OrchestrationEntityContext.cs b/src/DurableTask.Core/Entities/OrchestrationEntityContext.cs index 458e44967..c93d0ee4a 100644 --- a/src/DurableTask.Core/Entities/OrchestrationEntityContext.cs +++ b/src/DurableTask.Core/Entities/OrchestrationEntityContext.cs @@ -61,7 +61,7 @@ public OrchestrationEntityContext( /// /// Checks whether the configured backend supports entities. /// - public bool EntitiesAreSupported => this.innerContext.EntityBackendProperties != null; + public bool EntitiesAreSupported => this.innerContext.EntityParameters != null; /// /// Whether this orchestration is currently inside a critical section. @@ -312,7 +312,7 @@ internal void AdjustOutgoingMessage(string instanceId, RequestMessage requestMes requestMessage, instanceId, this.innerContext.CurrentUtcDateTime, - this.innerContext.EntityBackendProperties.EntityMessageReorderWindow); + this.innerContext.EntityParameters.EntityMessageReorderWindow); eventName = EntityMessageEventNames.RequestMessageEventName; } diff --git a/src/DurableTask.Core/Entities/TaskOrchestrationEntityParameters.cs b/src/DurableTask.Core/Entities/TaskOrchestrationEntityParameters.cs new file mode 100644 index 000000000..758710ad1 --- /dev/null +++ b/src/DurableTask.Core/Entities/TaskOrchestrationEntityParameters.cs @@ -0,0 +1,48 @@ +// ---------------------------------------------------------------------------------- +// Copyright Microsoft Corporation +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// ---------------------------------------------------------------------------------- +#nullable enable +namespace DurableTask.Core.Entities +{ + using System; + using DurableTask.Core.Serializing; + + /// + /// Settings that determine how a task orchestrator interacts with entities. + /// + public class TaskOrchestrationEntityParameters + { + /// + /// The time window within which entity messages should be deduplicated and reordered. + /// This is zero for providers that already guarantee exactly-once and ordered delivery. + /// + public TimeSpan EntityMessageReorderWindow { get; set; } + + /// + /// Construct a based on the given backend properties. + /// + /// The backend properties. + /// The constructed object, or null if is null. + public static TaskOrchestrationEntityParameters? FromEntityBackendProperties(EntityBackendProperties? properties) + { + if (properties == null) + { + return null; + } + + return new TaskOrchestrationEntityParameters() + { + EntityMessageReorderWindow = properties.EntityMessageReorderWindow, + }; + } + } +} \ No newline at end of file diff --git a/src/DurableTask.Core/OrchestrationContext.cs b/src/DurableTask.Core/OrchestrationContext.cs index 39f907542..290fc9ae1 100644 --- a/src/DurableTask.Core/OrchestrationContext.cs +++ b/src/DurableTask.Core/OrchestrationContext.cs @@ -71,7 +71,7 @@ public abstract class OrchestrationContext /// /// Information about backend entity support, or null if the configured backend does not support entities. /// - internal EntityBackendProperties EntityBackendProperties { get; set; } + internal TaskOrchestrationEntityParameters EntityParameters { get; set; } /// /// Create a proxy client class to schedule remote TaskActivities via a strongly typed interface. diff --git a/src/DurableTask.Core/TaskEntityDispatcher.cs b/src/DurableTask.Core/TaskEntityDispatcher.cs index c6c45fdd5..10399a1c3 100644 --- a/src/DurableTask.Core/TaskEntityDispatcher.cs +++ b/src/DurableTask.Core/TaskEntityDispatcher.cs @@ -867,12 +867,6 @@ await this.dispatchPipeline.RunAsync(dispatchContext, async _ => new TypeMissingException($"Entity not found: {entityName}")); } - var options = new EntityExecutionOptions() - { - EntityBackendProperties = this.entityBackendProperties, - ErrorPropagationMode = this.errorPropagationMode, - }; - var result = await taskEntity.ExecuteOperationBatchAsync(request); dispatchContext.SetProperty(result); diff --git a/src/DurableTask.Core/TaskOrchestrationContext.cs b/src/DurableTask.Core/TaskOrchestrationContext.cs index a616d3e4a..47535ff06 100644 --- a/src/DurableTask.Core/TaskOrchestrationContext.cs +++ b/src/DurableTask.Core/TaskOrchestrationContext.cs @@ -48,7 +48,7 @@ public void AddEventToNextIteration(HistoryEvent he) public TaskOrchestrationContext( OrchestrationInstance orchestrationInstance, TaskScheduler taskScheduler, - EntityBackendProperties entityBackendProperties = null, + TaskOrchestrationEntityParameters entityParameters = null, ErrorPropagationMode errorPropagationMode = ErrorPropagationMode.SerializeExceptions) { Utils.UnusedParameter(taskScheduler); @@ -60,7 +60,7 @@ public TaskOrchestrationContext( this.ErrorDataConverter = JsonDataConverter.Default; OrchestrationInstance = orchestrationInstance; IsReplaying = false; - this.EntityBackendProperties = entityBackendProperties; + this.EntityParameters = entityParameters; ErrorPropagationMode = errorPropagationMode; this.eventsWhileSuspended = new Queue(); } diff --git a/src/DurableTask.Core/TaskOrchestrationDispatcher.cs b/src/DurableTask.Core/TaskOrchestrationDispatcher.cs index 1b243cb05..339865c86 100644 --- a/src/DurableTask.Core/TaskOrchestrationDispatcher.cs +++ b/src/DurableTask.Core/TaskOrchestrationDispatcher.cs @@ -45,6 +45,7 @@ public class TaskOrchestrationDispatcher readonly NonBlockingCountdownLock concurrentSessionLock; readonly IEntityOrchestrationService? entityOrchestrationService; readonly EntityBackendProperties? entityBackendProperties; + readonly TaskOrchestrationEntityParameters? entityParameters; internal TaskOrchestrationDispatcher( IOrchestrationService orchestrationService, @@ -60,6 +61,7 @@ internal TaskOrchestrationDispatcher( this.errorPropagationMode = errorPropagationMode; this.entityOrchestrationService = orchestrationService as IEntityOrchestrationService; this.entityBackendProperties = this.entityOrchestrationService?.EntityBackendProperties; + this.entityParameters = TaskOrchestrationEntityParameters.FromEntityBackendProperties(this.entityBackendProperties); this.dispatcher = new WorkItemDispatcher( "TaskOrchestrationDispatcher", @@ -681,6 +683,7 @@ async Task ExecuteOrchestrationAsync(Orchestration dispatchContext.SetProperty(runtimeState); dispatchContext.SetProperty(workItem); dispatchContext.SetProperty(GetOrchestrationExecutionContext(runtimeState)); + dispatchContext.SetProperty(this.entityParameters); TaskOrchestrationExecutor? executor = null; @@ -708,8 +711,9 @@ await this.dispatchPipeline.RunAsync(dispatchContext, _ => runtimeState, taskOrchestration, this.orchestrationService.EventBehaviourForContinueAsNew, - this.entityBackendProperties, - this.errorPropagationMode); ; + this.entityParameters, + this.errorPropagationMode); + OrchestratorExecutionResult resultFromOrchestrator = executor.Execute(); dispatchContext.SetProperty(resultFromOrchestrator); return CompletedTask; diff --git a/src/DurableTask.Core/TaskOrchestrationExecutor.cs b/src/DurableTask.Core/TaskOrchestrationExecutor.cs index 2272fddd4..af8b850bf 100644 --- a/src/DurableTask.Core/TaskOrchestrationExecutor.cs +++ b/src/DurableTask.Core/TaskOrchestrationExecutor.cs @@ -43,22 +43,21 @@ public class TaskOrchestrationExecutor /// /// /// - /// + /// /// public TaskOrchestrationExecutor( OrchestrationRuntimeState orchestrationRuntimeState, TaskOrchestration taskOrchestration, BehaviorOnContinueAsNew eventBehaviourForContinueAsNew, - EntityBackendProperties? entityBackendProperties, + TaskOrchestrationEntityParameters? entityParameters, ErrorPropagationMode errorPropagationMode = ErrorPropagationMode.SerializeExceptions) { this.decisionScheduler = new SynchronousTaskScheduler(); this.context = new TaskOrchestrationContext( orchestrationRuntimeState.OrchestrationInstance, this.decisionScheduler, - entityBackendProperties, - errorPropagationMode - ); + entityParameters, + errorPropagationMode); this.orchestrationRuntimeState = orchestrationRuntimeState; this.taskOrchestration = taskOrchestration; this.skipCarryOverEvents = eventBehaviourForContinueAsNew == BehaviorOnContinueAsNew.Ignore; @@ -77,7 +76,7 @@ public TaskOrchestrationExecutor( TaskOrchestration taskOrchestration, BehaviorOnContinueAsNew eventBehaviourForContinueAsNew, ErrorPropagationMode errorPropagationMode = ErrorPropagationMode.SerializeExceptions) - : this(orchestrationRuntimeState, taskOrchestration, eventBehaviourForContinueAsNew, null, errorPropagationMode) + : this(orchestrationRuntimeState, taskOrchestration, eventBehaviourForContinueAsNew, entityParameters: null, errorPropagationMode) { }