File tree Expand file tree Collapse file tree 3 files changed +26
-8
lines changed
src/providers/WorkflowCore.Persistence.MongoDB Expand file tree Collapse file tree 3 files changed +26
-8
lines changed Original file line number Diff line number Diff line change 11using MongoDB . Driver ;
22using System ;
3- using System . Linq ;
43using WorkflowCore . Interface ;
54using WorkflowCore . Models ;
65using WorkflowCore . Persistence . MongoDB . Services ;
@@ -33,5 +32,26 @@ public static WorkflowOptions UseMongoDB(
3332 } ) ;
3433 return options ;
3534 }
35+
36+ public static WorkflowOptions UseMongoDB (
37+ this WorkflowOptions options ,
38+ Func < IServiceProvider , IMongoDatabase > createDatabase )
39+ {
40+ if ( options == null ) throw new ArgumentNullException ( nameof ( options ) ) ;
41+ if ( createDatabase == null ) throw new ArgumentNullException ( nameof ( createDatabase ) ) ;
42+
43+ options . UsePersistence ( sp =>
44+ {
45+ var db = createDatabase ( sp ) ;
46+ return new MongoPersistenceProvider ( db ) ;
47+ } ) ;
48+ options . Services . AddTransient < IWorkflowPurger > ( sp =>
49+ {
50+ var db = createDatabase ( sp ) ;
51+ return new WorkflowPurger ( db ) ;
52+ } ) ;
53+
54+ return options ;
55+ }
3656 }
3757}
Original file line number Diff line number Diff line change 1212using WorkflowCore . Interface ;
1313using WorkflowCore . Models ;
1414using System . Threading ;
15- using MongoDB . Extensions . Transactions ;
1615
1716namespace WorkflowCore . Persistence . MongoDB . Services
1817{
@@ -116,13 +115,13 @@ static void CreateIndexes(MongoPersistenceProvider instance)
116115 }
117116 }
118117
119- private IMongoCollection < WorkflowInstance > WorkflowInstances => _database . GetCollection < WorkflowInstance > ( WorkflowCollectionName ) . AsTransactionCollection ( ) ;
118+ private IMongoCollection < WorkflowInstance > WorkflowInstances => _database . GetCollection < WorkflowInstance > ( WorkflowCollectionName ) ;
120119
121- private IMongoCollection < EventSubscription > EventSubscriptions => _database . GetCollection < EventSubscription > ( "wfc.subscriptions" ) . AsTransactionCollection ( ) ;
120+ private IMongoCollection < EventSubscription > EventSubscriptions => _database . GetCollection < EventSubscription > ( "wfc.subscriptions" ) ;
122121
123- private IMongoCollection < Event > Events => _database . GetCollection < Event > ( "wfc.events" ) . AsTransactionCollection ( ) ;
122+ private IMongoCollection < Event > Events => _database . GetCollection < Event > ( "wfc.events" ) ;
124123
125- private IMongoCollection < ExecutionError > ExecutionErrors => _database . GetCollection < ExecutionError > ( "wfc.execution_errors" ) . AsTransactionCollection ( ) ;
124+ private IMongoCollection < ExecutionError > ExecutionErrors => _database . GetCollection < ExecutionError > ( "wfc.execution_errors" ) ;
126125
127126 public async Task < string > CreateNewWorkflow ( WorkflowInstance workflow , CancellationToken cancellationToken = default )
128127 {
Original file line number Diff line number Diff line change 2222 </ItemGroup >
2323
2424 <ItemGroup >
25- <PackageReference Include =" MongoDB.Driver" Version =" 2.12.2" />
26- <PackageReference Include =" MongoDB.Extensions.Transactions" Version =" 0.8.0" />
25+ <PackageReference Include =" MongoDB.Driver" Version =" 2.8.1" />
2726 <PackageReference Include =" Newtonsoft.Json" Version =" 12.0.1" />
2827 </ItemGroup >
2928
You can’t perform that action at this time.
0 commit comments