File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed
src/providers/WorkflowCore.Persistence.MongoDB Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -9,17 +9,25 @@ namespace Microsoft.Extensions.DependencyInjection
9
9
{
10
10
public static class ServiceCollectionExtensions
11
11
{
12
- public static WorkflowOptions UseMongoDB ( this WorkflowOptions options , string mongoUrl , string databaseName )
12
+ public static WorkflowOptions UseMongoDB (
13
+ this WorkflowOptions options ,
14
+ string mongoUrl ,
15
+ string databaseName ,
16
+ Action < MongoClientSettings > configureClient = default )
13
17
{
14
18
options . UsePersistence ( sp =>
15
19
{
16
- var client = new MongoClient ( mongoUrl ) ;
20
+ var mongoClientSettings = MongoClientSettings . FromConnectionString ( mongoUrl ) ;
21
+ configureClient ? . Invoke ( mongoClientSettings ) ;
22
+ var client = new MongoClient ( mongoClientSettings ) ;
17
23
var db = client . GetDatabase ( databaseName ) ;
18
24
return new MongoPersistenceProvider ( db ) ;
19
25
} ) ;
20
26
options . Services . AddTransient < IWorkflowPurger > ( sp =>
21
27
{
22
- var client = new MongoClient ( mongoUrl ) ;
28
+ var mongoClientSettings = MongoClientSettings . FromConnectionString ( mongoUrl ) ;
29
+ configureClient ? . Invoke ( mongoClientSettings ) ;
30
+ var client = new MongoClient ( mongoClientSettings ) ;
23
31
var db = client . GetDatabase ( databaseName ) ;
24
32
return new WorkflowPurger ( db ) ;
25
33
} ) ;
You can’t perform that action at this time.
0 commit comments