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 1
1
using MongoDB . Driver ;
2
2
using System ;
3
- using System . Linq ;
4
3
using WorkflowCore . Interface ;
5
4
using WorkflowCore . Models ;
6
5
using WorkflowCore . Persistence . MongoDB . Services ;
@@ -33,5 +32,26 @@ public static WorkflowOptions UseMongoDB(
33
32
} ) ;
34
33
return options ;
35
34
}
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
+ }
36
56
}
37
57
}
Original file line number Diff line number Diff line change 12
12
using WorkflowCore . Interface ;
13
13
using WorkflowCore . Models ;
14
14
using System . Threading ;
15
- using MongoDB . Extensions . Transactions ;
16
15
17
16
namespace WorkflowCore . Persistence . MongoDB . Services
18
17
{
@@ -116,13 +115,13 @@ static void CreateIndexes(MongoPersistenceProvider instance)
116
115
}
117
116
}
118
117
119
- private IMongoCollection < WorkflowInstance > WorkflowInstances => _database . GetCollection < WorkflowInstance > ( WorkflowCollectionName ) . AsTransactionCollection ( ) ;
118
+ private IMongoCollection < WorkflowInstance > WorkflowInstances => _database . GetCollection < WorkflowInstance > ( WorkflowCollectionName ) ;
120
119
121
- private IMongoCollection < EventSubscription > EventSubscriptions => _database . GetCollection < EventSubscription > ( "wfc.subscriptions" ) . AsTransactionCollection ( ) ;
120
+ private IMongoCollection < EventSubscription > EventSubscriptions => _database . GetCollection < EventSubscription > ( "wfc.subscriptions" ) ;
122
121
123
- private IMongoCollection < Event > Events => _database . GetCollection < Event > ( "wfc.events" ) . AsTransactionCollection ( ) ;
122
+ private IMongoCollection < Event > Events => _database . GetCollection < Event > ( "wfc.events" ) ;
124
123
125
- private IMongoCollection < ExecutionError > ExecutionErrors => _database . GetCollection < ExecutionError > ( "wfc.execution_errors" ) . AsTransactionCollection ( ) ;
124
+ private IMongoCollection < ExecutionError > ExecutionErrors => _database . GetCollection < ExecutionError > ( "wfc.execution_errors" ) ;
126
125
127
126
public async Task < string > CreateNewWorkflow ( WorkflowInstance workflow , CancellationToken cancellationToken = default )
128
127
{
Original file line number Diff line number Diff line change 22
22
</ItemGroup >
23
23
24
24
<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" />
27
26
<PackageReference Include =" Newtonsoft.Json" Version =" 12.0.1" />
28
27
</ItemGroup >
29
28
You can’t perform that action at this time.
0 commit comments