@@ -22,18 +22,19 @@ public static class IServiceCollectionExtensions
2222 /// <param name="serviceCollection">The service collection.</param>
2323 /// <param name="keyNamespace">The namespace used to build a Redis key.</param>
2424 /// <param name="getConnectionString">A function that retrieves the Redis connection string.</param>
25+ /// <param name="synchronousMode">If <c>true</c> then snapshots will be synchronously recorded.</param>
2526 /// <remarks>
2627 /// The production-ready implementation will store snapshots as they come in. If you need write an integration test,
2728 /// consider using
28- /// <see cref="AddTestModeRedisSnapshots{TEntity}(IServiceCollection, string, Func{IConfiguration, string})" />
29+ /// <see cref="AddTestModeRedisSnapshots{TEntity}(IServiceCollection, string, Func{IConfiguration, string}, bool )" />
2930 /// instead.
3031 /// </remarks>
3132 [ ExcludeFromCodeCoverage ( Justification = "Tests use TestMode." ) ]
3233 public static void AddRedisSnapshots < TEntity > ( this IServiceCollection serviceCollection , string keyNamespace ,
33- Func < IConfiguration , string > getConnectionString )
34+ Func < IConfiguration , string > getConnectionString , bool synchronousMode = false )
3435 {
3536 serviceCollection . AddSingleton < ITransactionSubscriber < TEntity > > ( serviceProvider =>
36- SnapshottingTransactionSubscriber < TEntity > . Create ( serviceProvider , false ) ) ;
37+ SnapshottingTransactionSubscriber < TEntity > . Create ( serviceProvider , synchronousMode ) ) ;
3738
3839 serviceCollection . AddSingleton < ISnapshotRepositoryFactory < TEntity > > ( serviceProvider =>
3940 {
@@ -55,15 +56,16 @@ public static void AddRedisSnapshots<TEntity>(this IServiceCollection serviceCol
5556 /// <param name="serviceCollection">The service collection.</param>
5657 /// <param name="keyNamespace">The namespace used to build a Redis key.</param>
5758 /// <param name="getConnectionString">A function that retrieves the Redis connection string.</param>
59+ /// <param name="synchronousMode">If <c>true</c> then snapshots will be synchronously recorded.</param>
5860 /// <remarks>
5961 /// The test-mode implementation will store snapshots as they come in, but the snapshots will be automatically removed
6062 /// when the repository is disposed.
6163 /// </remarks>
6264 public static void AddTestModeRedisSnapshots < TEntity > ( this IServiceCollection serviceCollection ,
63- string keyNamespace , Func < IConfiguration , string > getConnectionString )
65+ string keyNamespace , Func < IConfiguration , string > getConnectionString , bool synchronousMode = true )
6466 {
6567 serviceCollection . AddSingleton < ITransactionSubscriber < TEntity > > ( serviceProvider =>
66- SnapshottingTransactionSubscriber < TEntity > . Create ( serviceProvider , true ) ) ;
68+ SnapshottingTransactionSubscriber < TEntity > . Create ( serviceProvider , synchronousMode ) ) ;
6769
6870 serviceCollection . AddSingleton < ISnapshotRepositoryFactory < TEntity > > ( serviceProvider =>
6971 {
0 commit comments