@@ -11,76 +11,49 @@ namespace Microsoft.DurableTask.Worker;
1111public class DurableTaskWorkerWorkItemFilters
1212{
1313 /// <summary>
14- /// Initializes a new instance of the <see cref="DurableTaskWorkerWorkItemFilters"/> class .
14+ /// Gets or initializes the orchestration filters .
1515 /// </summary>
16- public DurableTaskWorkerWorkItemFilters ( )
17- {
18- this . Orchestrations = [ ] ;
19- this . Activities = [ ] ;
20- this . Entities = [ ] ;
21- }
16+ public IReadOnlyList < OrchestrationFilter > Orchestrations { get ; init ; } = [ ] ;
17+
18+ /// <summary>
19+ /// Gets or initializes the activity filters.
20+ /// </summary>
21+ public IReadOnlyList < ActivityFilter > Activities { get ; init ; } = [ ] ;
2222
2323 /// <summary>
24- /// Initializes a new instance of the <see cref="DurableTaskWorkerWorkItemFilters"/> class.
24+ /// Gets or initializes the entity filters.
25+ /// </summary>
26+ public IReadOnlyList < EntityFilter > Entities { get ; init ; } = [ ] ;
27+
28+ /// <summary>
29+ /// Creates a new instance of the <see cref="DurableTaskWorkerWorkItemFilters"/> class.
2530 /// </summary>
2631 /// <param name="registry"><see cref="DurableTaskRegistry"/> to construct the filter from.</param>
2732 /// <param name="workerOptions"><see cref="DurableTaskWorkerOptions"/> that optionally provides versioning information.</param>
28- internal DurableTaskWorkerWorkItemFilters ( DurableTaskRegistry registry , DurableTaskWorkerOptions ? workerOptions )
33+ /// <returns>A new instance of <see cref="DurableTaskWorkerWorkItemFilters"/> constructed from the provided registry.</returns>
34+ internal static DurableTaskWorkerWorkItemFilters FromDurableTaskRegistry ( DurableTaskRegistry registry , DurableTaskWorkerOptions ? workerOptions )
2935 {
30- List < OrchestrationFilter > orchestrationActions = new ( ) ;
31- foreach ( var orchestration in registry . Orchestrators )
36+ // TODO: Support multiple versions per orchestration/activity. For now, grab the worker version from the options.
37+ return new DurableTaskWorkerWorkItemFilters
3238 {
33- orchestrationActions . Add ( new OrchestrationFilter
39+ Orchestrations = registry . Orchestrators . Select ( orchestration => new OrchestrationFilter
3440 {
3541 Name = orchestration . Key ,
36-
37- // TODO: Support multiple orchestration versions, for now, utilize the Worker's version.
3842 Versions = workerOptions ? . Versioning != null ? [ workerOptions . Versioning . DefaultVersion ] : [ ] ,
39- } ) ;
40- }
41-
42- this . Orchestrations = orchestrationActions ;
43- List < ActivityFilter > activityActions = new ( ) ;
44- foreach ( var activity in registry . Activities )
45- {
46- activityActions . Add ( new ActivityFilter
43+ } ) . ToList ( ) ,
44+ Activities = registry . Activities . Select ( activity => new ActivityFilter
4745 {
4846 Name = activity . Key ,
49-
50- // TODO: Support multiple activity versions, for now, utilize the Worker's version.
5147 Versions = workerOptions ? . Versioning != null ? [ workerOptions . Versioning . DefaultVersion ] : [ ] ,
52- } ) ;
53- }
54-
55- this . Activities = activityActions ;
56- List < EntityFilter > entityActions = new ( ) ;
57- foreach ( var entity in registry . Entities )
58- {
59- entityActions . Add ( new EntityFilter
48+ } ) . ToList ( ) ,
49+ Entities = registry . Entities . Select ( entity => new EntityFilter
6050 {
6151 // Entity names are normalized to lowercase in the backend.
6252 Name = entity . Key . ToString ( ) . ToLowerInvariant ( ) ,
63- } ) ;
64- }
65-
66- this . Entities = entityActions ;
53+ } ) . ToList ( ) ,
54+ } ;
6755 }
6856
69- /// <summary>
70- /// Gets or initializes the orchestration filters.
71- /// </summary>
72- public IReadOnlyList < OrchestrationFilter > Orchestrations { get ; init ; }
73-
74- /// <summary>
75- /// Gets or initializes the activity filters.
76- /// </summary>
77- public IReadOnlyList < ActivityFilter > Activities { get ; init ; }
78-
79- /// <summary>
80- /// Gets or initializes the entity filters.
81- /// </summary>
82- public IReadOnlyList < EntityFilter > Entities { get ; init ; }
83-
8457 /// <summary>
8558 /// Struct specifying an orchestration filter.
8659 /// </summary>
@@ -94,7 +67,7 @@ public struct OrchestrationFilter
9467 /// <summary>
9568 /// Gets or initializes the versions of the orchestration to filter.
9669 /// </summary>
97- public List < string > Versions { get ; init ; }
70+ public IReadOnlyList < string > Versions { get ; init ; }
9871 }
9972
10073 /// <summary>
@@ -110,7 +83,7 @@ public struct ActivityFilter
11083 /// <summary>
11184 /// Gets or initializes the versions of the activity to filter.
11285 /// </summary>
113- public List < string > Versions { get ; init ; }
86+ public IReadOnlyList < string > Versions { get ; init ; }
11487 }
11588
11689 /// <summary>
0 commit comments