From 49b309bec72d653af9b6699b88cbe568598725da Mon Sep 17 00:00:00 2001 From: Sky Ao Date: Mon, 22 Apr 2024 17:27:56 +0800 Subject: [PATCH 1/5] Add override StartNewAsync() method to set instanceVersion Signed-off-by: Sky Ao --- .../IDurableOrchestrationClient.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/WebJobs.Extensions.DurableTask/ContextInterfaces/IDurableOrchestrationClient.cs b/src/WebJobs.Extensions.DurableTask/ContextInterfaces/IDurableOrchestrationClient.cs index b3113f7a3..95377f619 100644 --- a/src/WebJobs.Extensions.DurableTask/ContextInterfaces/IDurableOrchestrationClient.cs +++ b/src/WebJobs.Extensions.DurableTask/ContextInterfaces/IDurableOrchestrationClient.cs @@ -162,6 +162,25 @@ Task StartNewAsync( /// Task StartNewAsync(string orchestratorFunctionName, string instanceId, T input); + /// + /// Starts a new instance of the specified orchestrator function. + /// + /// + /// If an orchestration instance with the specified ID already exists, the existing instance + /// will be silently replaced by this new instance. + /// + /// The name of the orchestrator function to start. + /// The ID to use for the new orchestration instance. + /// The version to use for the new orchestration instance. + /// JSON-serializable input value for the orchestrator function. + /// The type of the input value for the orchestrator function. + /// A task that completes when the orchestration is started. The task contains the instance id of the started + /// orchestratation instance. + /// + /// The specified function does not exist, is disabled, or is not an orchestrator function. + /// + Task StartNewAsync(string orchestratorFunctionName, string instanceId, string instanceVersion, T input); + /// /// Sends an event notification message to a waiting orchestration instance. /// From acfeaaa7683444e5d7abfef527f6745decd82cb1 Mon Sep 17 00:00:00 2001 From: Sky Ao Date: Mon, 22 Apr 2024 17:28:38 +0800 Subject: [PATCH 2/5] Update StartNewAsync() method to set instanceVersion correctly to call TaskHubClient.CreateOrchestrationInstanceAsync() method Signed-off-by: Sky Ao --- .../ContextImplementations/DurableClient.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableClient.cs b/src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableClient.cs index 7e6709a2c..642482cbd 100644 --- a/src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableClient.cs +++ b/src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableClient.cs @@ -175,7 +175,7 @@ async Task IDurableOrchestrationClient.WaitForCompletionOrCreateC } /// - async Task IDurableOrchestrationClient.StartNewAsync(string orchestratorFunctionName, string instanceId, T input) + async Task IDurableOrchestrationClient.StartNewAsync(string orchestratorFunctionName, string instanceId, string instanceVersion, T input) { if (this.ClientReferencesCurrentApp(this)) { @@ -202,7 +202,7 @@ async Task IDurableOrchestrationClient.StartNewAsync(string orchestra OrchestrationStatus[] dedupeStatuses = this.GetStatusesNotToOverride(); Task createTask = this.client.CreateOrchestrationInstanceAsync( - orchestratorFunctionName, DefaultVersion, instanceId, input, null, dedupeStatuses); + orchestratorFunctionName, instanceVersion, instanceId, input, null, dedupeStatuses); this.traceHelper.FunctionScheduled( this.TaskHubName, @@ -1139,6 +1139,12 @@ Task IDurableOrchestrationClient.StartNewAsync(string orchestratorFun return ((IDurableOrchestrationClient)this).StartNewAsync(orchestratorFunctionName, string.Empty, input); } + /// + Task IDurableOrchestrationClient.StartNewAsync(string orchestratorFunctionName, string instanceId, T input) + { + return ((IDurableOrchestrationClient)this).StartNewAsync(orchestratorFunctionName, instanceId, string.Empty, input); + } + async Task IDurableOrchestrationClient.RestartAsync(string instanceId, bool restartWithNewInstanceId) { DurableOrchestrationStatus status = await ((IDurableOrchestrationClient)this).GetStatusAsync(instanceId, showHistory: false, showHistoryOutput: false, showInput: true); From 70e56a038eccbf551fafc883358e0560c40abeeb Mon Sep 17 00:00:00 2001 From: Sky Ao Date: Mon, 22 Apr 2024 17:29:06 +0800 Subject: [PATCH 3/5] Update to call IDurableOrchestrationClient.StartNewAsync() method with version from CreateInstanceRequest Signed-off-by: Sky Ao --- src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs b/src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs index a62b377b1..6c236e041 100644 --- a/src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs +++ b/src/WebJobs.Extensions.DurableTask/LocalGrpcListener.cs @@ -156,7 +156,7 @@ public override Task Hello(Empty request, ServerCallContext context) try { string instanceId = await this.GetClient(context).StartNewAsync( - request.Name, request.InstanceId, Raw(request.Input)); + request.Name, request.InstanceId, request.Version, Raw(request.Input)); return new P.CreateInstanceResponse { InstanceId = instanceId, From d5b1b159d4d25b60bf57addafbe58b0b29bf6c05 Mon Sep 17 00:00:00 2001 From: Sky Ao Date: Mon, 22 Apr 2024 17:30:23 +0800 Subject: [PATCH 4/5] Auto update for new added override StartNewAsync() method with instanceVersion parameter Signed-off-by: Sky Ao --- ...t.Azure.WebJobs.Extensions.DurableTask.xml | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml index 0088042e9..5166c0ee4 100644 --- a/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml +++ b/src/WebJobs.Extensions.DurableTask/Microsoft.Azure.WebJobs.Extensions.DurableTask.xml @@ -175,7 +175,7 @@ - + @@ -226,6 +226,9 @@ + + + @@ -953,6 +956,25 @@ The specified function does not exist, is disabled, or is not an orchestrator function. + + + Starts a new instance of the specified orchestrator function. + + + If an orchestration instance with the specified ID already exists, the existing instance + will be silently replaced by this new instance. + + The name of the orchestrator function to start. + The ID to use for the new orchestration instance. + The version to use for the new orchestration instance. + JSON-serializable input value for the orchestrator function. + The type of the input value for the orchestrator function. + A task that completes when the orchestration is started. The task contains the instance id of the started + orchestratation instance. + + The specified function does not exist, is disabled, or is not an orchestrator function. + + Sends an event notification message to a waiting orchestration instance. From f829e9ddec54937c4fd54176b7667245bd0d56cc Mon Sep 17 00:00:00 2001 From: Sky Ao Date: Mon, 22 Apr 2024 17:31:04 +0800 Subject: [PATCH 5/5] Implemented new added abstract method to get instance version Signed-off-by: Sky Ao --- .../FunctionsOrchestrationContext.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Worker.Extensions.DurableTask/FunctionsOrchestrationContext.cs b/src/Worker.Extensions.DurableTask/FunctionsOrchestrationContext.cs index 53b7cca9e..292e18d06 100644 --- a/src/Worker.Extensions.DurableTask/FunctionsOrchestrationContext.cs +++ b/src/Worker.Extensions.DurableTask/FunctionsOrchestrationContext.cs @@ -42,6 +42,8 @@ public FunctionsOrchestrationContext(TaskOrchestrationContext innerContext, Func public override string InstanceId => this.innerContext.InstanceId; + public override string InstanceVersion => this.innerContext.InstanceVersion; + public override DateTime CurrentUtcDateTime => this.innerContext.CurrentUtcDateTime; public override bool IsReplaying => this.innerContext.IsReplaying;