1- using System ;
2- using System . Collections . Generic ;
3- using System . Linq ;
4- using Cleipnir . Flows . CrossCutting ;
1+ using System ;
52using Cleipnir . ResilientFunctions . Domain ;
63
74namespace Cleipnir . Flows ;
85
96public class FlowOptions
107{
118 public static FlowOptions Default { get ; } = new ( ) ;
12-
9+
1310 internal TimeSpan ? RetentionPeriod { get ; }
1411 internal bool ? EnableWatchdogs { get ; }
1512 internal int ? MaxParallelRetryInvocations { get ; }
1613 internal TimeSpan ? MessagesDefaultMaxWaitForCompletion { get ; }
17- internal List < MiddlewareInstanceOrType > Middlewares { get ; } = new ( ) ;
1814
1915 public FlowOptions (
2016 TimeSpan ? retentionPeriod = null ,
2117 bool ? enableWatchdogs = null ,
22- TimeSpan ? messagesDefaultMaxWaitForCompletion = null ,
18+ TimeSpan ? messagesDefaultMaxWaitForCompletion = null ,
2319 int ? maxParallelRetryInvocations = null
2420 )
2521 {
@@ -29,37 +25,16 @@ public FlowOptions(
2925 MaxParallelRetryInvocations = maxParallelRetryInvocations ;
3026 }
3127
32- public FlowOptions UseMiddleware < TMiddleware > ( ) where TMiddleware : IMiddleware
33- {
34- Middlewares . Add ( new MiddlewareType ( typeof ( TMiddleware ) ) ) ;
35- return this ;
36- }
37-
38- public FlowOptions UseMiddleware ( IMiddleware middleware )
39- {
40- Middlewares . Add ( new MiddlewareInstance ( middleware ) ) ;
41- return this ;
42- }
43-
4428 public FlowOptions Merge ( Options options )
4529 {
46- var merged = new FlowOptions (
30+ return new FlowOptions (
4731 RetentionPeriod ?? options . RetentionPeriod ,
4832 EnableWatchdogs ?? options . EnableWatchdogs ,
4933 MessagesDefaultMaxWaitForCompletion ?? options . MessagesDefaultMaxWaitForCompletion ,
5034 MaxParallelRetryInvocations ?? options . MaxParallelRetryInvocations
5135 ) ;
52-
53- if ( Middlewares . Any ( ) )
54- foreach ( var middleware in Middlewares )
55- merged . Middlewares . Add ( middleware ) ;
56- else
57- foreach ( var middleware in options . Middlewares )
58- merged . Middlewares . Add ( middleware ) ;
59-
60- return merged ;
6136 }
6237
6338 internal LocalSettings MapToLocalSettings ( )
6439 => new ( RetentionPeriod , EnableWatchdogs , MessagesDefaultMaxWaitForCompletion , MaxParallelRetryInvocations ) ;
65- }
40+ }
0 commit comments