Skip to content

Commit e494445

Browse files
authored
Merge pull request #863 from glucaci/diagnostics
Allow mongo client configuration
2 parents d605615 + a94f0b1 commit e494445

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/providers/WorkflowCore.Persistence.MongoDB/ServiceCollectionExtensions.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,25 @@ namespace Microsoft.Extensions.DependencyInjection
99
{
1010
public static class ServiceCollectionExtensions
1111
{
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)
1317
{
1418
options.UsePersistence(sp =>
1519
{
16-
var client = new MongoClient(mongoUrl);
20+
var mongoClientSettings = MongoClientSettings.FromConnectionString(mongoUrl);
21+
configureClient?.Invoke(mongoClientSettings);
22+
var client = new MongoClient(mongoClientSettings);
1723
var db = client.GetDatabase(databaseName);
1824
return new MongoPersistenceProvider(db);
1925
});
2026
options.Services.AddTransient<IWorkflowPurger>(sp =>
2127
{
22-
var client = new MongoClient(mongoUrl);
28+
var mongoClientSettings = MongoClientSettings.FromConnectionString(mongoUrl);
29+
configureClient?.Invoke(mongoClientSettings);
30+
var client = new MongoClient(mongoClientSettings);
2331
var db = client.GetDatabase(databaseName);
2432
return new WorkflowPurger(db);
2533
});

0 commit comments

Comments
 (0)