File tree Expand file tree Collapse file tree 6 files changed +50
-3
lines changed
Cleipnir.ResilientFunctions/Messaging
Cleipnir.ResilientFunctions.Tests
InMemoryTests/RFunctionTests
TestTemplates/FunctionTests
MariaDB/Cleipnir.ResilientFunctions.MariaDB.Tests/RFunctionTests
PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL.Tests/RFunctionTests
SqlServer/Cleipnir.ResilientFunctions.SqlServer.Tests/RFunctionTests Expand file tree Collapse file tree 6 files changed +50
-3
lines changed Original file line number Diff line number Diff line change @@ -91,4 +91,8 @@ public override Task ExecutingFlowIsReExecutedWhenSuspendedAfterInterrupt()
91
91
[ TestMethod ]
92
92
public override Task InterruptSuspendedFlows ( )
93
93
=> InterruptSuspendedFlows ( FunctionStoreFactory . Create ( ) ) ;
94
+
95
+ [ TestMethod ]
96
+ public override Task AwaitMessageAfterAppendShouldNotCauseSuspension ( )
97
+ => AwaitMessageAfterAppendShouldNotCauseSuspension ( FunctionStoreFactory . Create ( ) ) ;
94
98
}
Original file line number Diff line number Diff line change @@ -742,4 +742,35 @@ protected async Task InterruptSuspendedFlows(Task<IFunctionStore> storeTask)
742
742
743
743
unhandledExceptionHandler . ShouldNotHaveExceptions ( ) ;
744
744
}
745
+
746
+ public abstract Task AwaitMessageAfterAppendShouldNotCauseSuspension ( ) ;
747
+ protected async Task AwaitMessageAfterAppendShouldNotCauseSuspension ( Task < IFunctionStore > storeTask )
748
+ {
749
+ var store = await storeTask ;
750
+ var id = TestFlowId . Create ( ) ;
751
+ var ( flowType , flowInstance ) = id ;
752
+
753
+ var unhandledExceptionHandler = new UnhandledExceptionCatcher ( ) ;
754
+ using var functionsRegistry = new FunctionsRegistry
755
+ (
756
+ store ,
757
+ new Settings ( unhandledExceptionHandler . Catch )
758
+ ) ;
759
+
760
+ var registration = functionsRegistry . RegisterFunc < string , string > (
761
+ flowType ,
762
+ inner : async Task < string > ( param , workflow ) =>
763
+ {
764
+ var messages = workflow . Messages ;
765
+ await messages . AppendMessage ( param ) ;
766
+
767
+ return await messages . FirstOfType < string > ( ) ;
768
+ }
769
+ ) ;
770
+
771
+ var result = await registration . Invoke ( "SomeInstance" , "Hello World" ) ;
772
+ result . ShouldBe ( "Hello World" ) ;
773
+
774
+ unhandledExceptionHandler . ShouldNotHaveExceptions ( ) ;
775
+ }
745
776
}
Original file line number Diff line number Diff line change @@ -84,8 +84,10 @@ public async Task PullEvents(TimeSpan maxSinceLastSynced)
84
84
try
85
85
{
86
86
var storedMessages = _initialMessages ?? await _messageStore . GetMessages ( _storedId , _skip ) ;
87
- _initialMessages = null ;
87
+ if ( _initialMessages != null && maxSinceLastSynced == TimeSpan . Zero )
88
+ storedMessages = storedMessages . Concat ( await _messageStore . GetMessages ( _storedId , _skip ) ) . ToList ( ) ;
88
89
90
+ _initialMessages = null ;
89
91
_lastSynced = _utcNow ( ) ;
90
92
_skip += storedMessages . Count ;
91
93
@@ -118,7 +120,5 @@ public async Task PullEvents(TimeSpan maxSinceLastSynced)
118
120
119
121
throw eventHandlingException ;
120
122
}
121
-
122
- return ;
123
123
}
124
124
}
Original file line number Diff line number Diff line change @@ -79,4 +79,8 @@ public override Task InterruptSuspendedFlows()
79
79
[ TestMethod ]
80
80
public override Task ChildIsCreatedWithParentsId ( )
81
81
=> ChildIsCreatedWithParentsId ( FunctionStoreFactory . Create ( ) ) ;
82
+
83
+ [ TestMethod ]
84
+ public override Task AwaitMessageAfterAppendShouldNotCauseSuspension ( )
85
+ => AwaitMessageAfterAppendShouldNotCauseSuspension ( FunctionStoreFactory . Create ( ) ) ;
82
86
}
Original file line number Diff line number Diff line change @@ -80,4 +80,8 @@ public override Task InterruptSuspendedFlows()
80
80
[ TestMethod ]
81
81
public override Task ChildIsCreatedWithParentsId ( )
82
82
=> ChildIsCreatedWithParentsId ( FunctionStoreFactory . Create ( ) ) ;
83
+
84
+ [ TestMethod ]
85
+ public override Task AwaitMessageAfterAppendShouldNotCauseSuspension ( )
86
+ => AwaitMessageAfterAppendShouldNotCauseSuspension ( FunctionStoreFactory . Create ( ) ) ;
83
87
}
Original file line number Diff line number Diff line change @@ -80,4 +80,8 @@ public override Task ExecutingFlowIsReExecutedWhenSuspendedAfterInterrupt()
80
80
[ TestMethod ]
81
81
public override Task InterruptSuspendedFlows ( )
82
82
=> InterruptSuspendedFlows ( FunctionStoreFactory . Create ( ) ) ;
83
+
84
+ [ TestMethod ]
85
+ public override Task AwaitMessageAfterAppendShouldNotCauseSuspension ( )
86
+ => AwaitMessageAfterAppendShouldNotCauseSuspension ( FunctionStoreFactory . Create ( ) ) ;
83
87
}
You can’t perform that action at this time.
0 commit comments