Skip to content

Commit 014c4e3

Browse files
committed
data: configure mongodb using connection string
1 parent bf70a32 commit 014c4e3

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

Streetwriters.Data/DbContexts/MongoDbContext.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ public class MongoDbContext(IMongoClient MongoClient) : IDbContext
3333
public static IMongoClient CreateMongoDbClient(IDbSettings dbSettings)
3434
{
3535
var settings = MongoClientSettings.FromConnectionString(dbSettings.ConnectionString);
36-
settings.MaxConnectionPoolSize = 500;
37-
settings.MinConnectionPoolSize = 0;
38-
settings.HeartbeatInterval = TimeSpan.FromSeconds(60);
3936
return new MongoClient(settings);
4037
}
4138

Streetwriters.Identity/Startup.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ You should have received a copy of the Affero GNU General Public License
5353
using Streetwriters.Identity.Jobs;
5454
using Streetwriters.Identity.Services;
5555
using Streetwriters.Identity.Validation;
56+
using IdentityServer4.MongoDB.Configuration;
5657

5758
namespace Streetwriters.Identity
5859
{
@@ -107,11 +108,6 @@ public void ConfigureServices(IServiceCollection services)
107108
options.UsersCollection = "users";
108109
// options.MigrationCollection = "migration";
109110
options.ConnectionString = connectionString;
110-
options.ClusterConfigurator = builder =>
111-
{
112-
builder.ConfigureConnectionPool((c) => c.With(maxConnections: 500, minConnections: 0));
113-
builder.ConfigureServer(s => s.With(heartbeatInterval: TimeSpan.FromSeconds(60)));
114-
};
115111
}).AddDefaultTokenProviders();
116112

117113
services.AddIdentityServer(
@@ -137,6 +133,11 @@ public void ConfigureServices(IServiceCollection services)
137133
.AddKeyManagement()
138134
.AddFileSystemPersistence(Path.Combine(WebHostEnvironment.ContentRootPath, @"keystore"));
139135

136+
services.Configure<MongoDBConfiguration>(options =>
137+
{
138+
options.ConnectionString = connectionString;
139+
});
140+
140141
services.Configure<DataProtectionTokenProviderOptions>(options =>
141142
{
142143
options.TokenLifespan = TimeSpan.FromHours(2);

0 commit comments

Comments
 (0)