From 6c41917ae326cbf7b619665eb39f07e704914b81 Mon Sep 17 00:00:00 2001
From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com>
Date: Wed, 7 May 2025 13:13:56 -0700
Subject: [PATCH 01/21] add tag to TaskScheduledEvent
---
src/DurableTask.Core/History/TaskScheduledEvent.cs | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/src/DurableTask.Core/History/TaskScheduledEvent.cs b/src/DurableTask.Core/History/TaskScheduledEvent.cs
index c0f9108d3..dab60fd93 100644
--- a/src/DurableTask.Core/History/TaskScheduledEvent.cs
+++ b/src/DurableTask.Core/History/TaskScheduledEvent.cs
@@ -84,5 +84,11 @@ public TaskScheduledEvent(int eventId)
///
[DataMember]
public DistributedTraceContext? ParentTraceContext { get; set; }
+
+ ///
+ /// Gets or sets a dictionary of tags of string, string
+ ///
+ [DataMember]
+ public IDictionary Tags { get; set; } = new Dictionary();
}
}
\ No newline at end of file
From ef1255a354d3558d6d17e8b2c1c4d1fe48a882f1 Mon Sep 17 00:00:00 2001
From: peterstone2017 <12449837+YunchuWang@users.noreply.github.com>
Date: Wed, 7 May 2025 13:28:00 -0700
Subject: [PATCH 02/21] more changes
---
.../Command/ScheduleTaskOrchestratorAction.cs | 7 +++++
src/DurableTask.Core/DurableTask.Core.csproj | 2 +-
.../History/TaskScheduledEvent.cs | 3 +-
src/DurableTask.Core/OrchestrationContext.cs | 29 +++++++++++++++++++
.../OrchestrationRuntimeState.cs | 1 +
.../TaskOrchestrationContext.cs | 29 ++++++++++++++-----
.../TaskOrchestrationDispatcher.cs | 9 ++++--
7 files changed, 67 insertions(+), 13 deletions(-)
diff --git a/src/DurableTask.Core/Command/ScheduleTaskOrchestratorAction.cs b/src/DurableTask.Core/Command/ScheduleTaskOrchestratorAction.cs
index f4c65b84c..4e3c0bf85 100644
--- a/src/DurableTask.Core/Command/ScheduleTaskOrchestratorAction.cs
+++ b/src/DurableTask.Core/Command/ScheduleTaskOrchestratorAction.cs
@@ -11,6 +11,8 @@
// limitations under the License.
// ----------------------------------------------------------------------------------
#nullable enable
+using System.Collections.Generic;
+
namespace DurableTask.Core.Command
{
///
@@ -41,5 +43,10 @@ public class ScheduleTaskOrchestratorAction : OrchestratorAction
// TODO: This property is not used and should be removed or made obsolete
internal string? Tasklist { get; set; }
+
+ ///
+ /// Gets or sets a dictionary of tags of string, string
+ ///
+ public IDictionary? Tags { get; set; }
}
}
\ No newline at end of file
diff --git a/src/DurableTask.Core/DurableTask.Core.csproj b/src/DurableTask.Core/DurableTask.Core.csproj
index 4bedc92a8..d50486c61 100644
--- a/src/DurableTask.Core/DurableTask.Core.csproj
+++ b/src/DurableTask.Core/DurableTask.Core.csproj
@@ -18,7 +18,7 @@
3
1
- 0
+ 1
$(MajorVersion).$(MinorVersion).$(PatchVersion)
$(VersionPrefix).0
diff --git a/src/DurableTask.Core/History/TaskScheduledEvent.cs b/src/DurableTask.Core/History/TaskScheduledEvent.cs
index dab60fd93..73f84ce15 100644
--- a/src/DurableTask.Core/History/TaskScheduledEvent.cs
+++ b/src/DurableTask.Core/History/TaskScheduledEvent.cs
@@ -13,6 +13,7 @@
#nullable enable
namespace DurableTask.Core.History
{
+ using System.Collections.Generic;
using System.Runtime.Serialization;
using DurableTask.Core.Tracing;
@@ -89,6 +90,6 @@ public TaskScheduledEvent(int eventId)
/// Gets or sets a dictionary of tags of string, string
///
[DataMember]
- public IDictionary Tags { get; set; } = new Dictionary();
+ public IDictionary? Tags { get; set; }
}
}
\ No newline at end of file
diff --git a/src/DurableTask.Core/OrchestrationContext.cs b/src/DurableTask.Core/OrchestrationContext.cs
index 4b2d8c7fe..95c810854 100644
--- a/src/DurableTask.Core/OrchestrationContext.cs
+++ b/src/DurableTask.Core/OrchestrationContext.cs
@@ -206,6 +206,22 @@ public virtual Task ScheduleWithRetry(string name, string version, RetryOp
var retryInterceptor = new RetryInterceptor(this, retryOptions, RetryCall);
return retryInterceptor.Invoke();
}
+
+ ///
+ /// Schedule a TaskActivity by type. Also retry on failure as per supplied policy.
+ ///
+ /// Return Type of the TaskActivity.Execute method
+ /// Name of the orchestration as specified by the ObjectCreator
+ /// Name of the orchestration as specified by the ObjectCreator
+ /// Retry policy
+ /// Dictionary of key/value tags associated with this instance
+ /// Parameters for the TaskActivity.Execute method
+ /// Task that represents the execution of the specified TaskActivity
+ public virtual Task ScheduleWithRetry(string name, string version, RetryOptions retryOptions,
+ IDictionary tags, params object[] parameters)
+ {
+ throw new NotImplementedException();
+ }
///
/// Create a sub-orchestration of the specified type. Also retry on failure as per supplied policy.
@@ -286,6 +302,19 @@ public virtual Task ScheduleTask(Type activityType, params obj
NameVersionHelper.GetDefaultVersion(activityType), parameters);
}
+ ///
+ /// Schedule a TaskActivity by type, version, and tags.
+ ///
+ /// Return Type of the TaskActivity.Execute method
+ /// Name of the orchestration as specified by the ObjectCreator
+ /// Name of the orchestration as specified by the ObjectCreator
+ /// Parameters for the TaskActivity.Execute method
+ /// Dictionary of key/value tags associated with this instance
+ public virtual Task ScheduleTask(string name, string version, IDictionary tags, params object[] parameters)
+ {
+ throw new NotImplementedException();
+ }
+
///
/// Schedule a TaskActivity by name and version.
///
diff --git a/src/DurableTask.Core/OrchestrationRuntimeState.cs b/src/DurableTask.Core/OrchestrationRuntimeState.cs
index 494071dbd..3c10fe693 100644
--- a/src/DurableTask.Core/OrchestrationRuntimeState.cs
+++ b/src/DurableTask.Core/OrchestrationRuntimeState.cs
@@ -368,6 +368,7 @@ HistoryEvent GenerateAbridgedEvent(HistoryEvent evt)
Name = taskScheduledEvent.Name,
Version = taskScheduledEvent.Version,
Input = "[..snipped..]",
+ Tags = taskScheduledEvent.Tags,
};
}
else if (evt is TaskCompletedEvent taskCompletedEvent)
diff --git a/src/DurableTask.Core/TaskOrchestrationContext.cs b/src/DurableTask.Core/TaskOrchestrationContext.cs
index 7908eeb07..bf561bbef 100644
--- a/src/DurableTask.Core/TaskOrchestrationContext.cs
+++ b/src/DurableTask.Core/TaskOrchestrationContext.cs
@@ -78,18 +78,32 @@ internal void ClearPendingActions()
continueAsNew = null;
}
- public override async Task ScheduleTask(string name, string version,
- params object[] parameters)
+ public override async Task ScheduleTask(string name, string version,
+ IDictionary tags, params object[] parameters)
{
- TResult result = await ScheduleTaskToWorker(name, version, null, parameters);
+ TResult result = await ScheduleTaskToWorker(name, version, null, tags, parameters);
return result;
}
- public async Task ScheduleTaskToWorker(string name, string version, string taskList,
+ public override async Task ScheduleTask(string name, string version,
params object[] parameters)
{
- object result = await ScheduleTaskInternal(name, version, taskList, typeof(TResult), parameters);
+ return await ScheduleTask(name, version, null, parameters);
+ }
+
+ public override async Task ScheduleWithRetry(string name, string version,
+ RetryOptions retryOptions, IDictionary tags, params object[] parameters)
+ {
+ Task RetryCall() => ScheduleTask(name, version, tags:tags, parameters:parameters);
+ var retryInterceptor = new RetryInterceptor(this, retryOptions, RetryCall);
+ return await retryInterceptor.Invoke();
+ }
+
+ public async Task ScheduleTaskToWorker(string name, string version, string taskList,
+ IDictionary tags, params object[] parameters)
+ {
+ object result = await ScheduleTaskInternal(name, version, taskList, typeof(TResult), tags:tags, parameters:parameters);
if (result == null)
{
@@ -99,8 +113,7 @@ public async Task ScheduleTaskToWorker(string name, string ver
return (TResult)result;
}
- public async Task