From 014c4e3b326a0f869038e190755c032e0e59c691 Mon Sep 17 00:00:00 2001 From: Abdullah Atta Date: Mon, 2 Feb 2026 22:33:32 +0500 Subject: [PATCH] data: configure mongodb using connection string --- Streetwriters.Data/DbContexts/MongoDbContext.cs | 3 --- Streetwriters.Identity/Startup.cs | 11 ++++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/Streetwriters.Data/DbContexts/MongoDbContext.cs b/Streetwriters.Data/DbContexts/MongoDbContext.cs index 55bc3f5..4b41cf5 100644 --- a/Streetwriters.Data/DbContexts/MongoDbContext.cs +++ b/Streetwriters.Data/DbContexts/MongoDbContext.cs @@ -33,9 +33,6 @@ namespace Streetwriters.Data.DbContexts public static IMongoClient CreateMongoDbClient(IDbSettings dbSettings) { var settings = MongoClientSettings.FromConnectionString(dbSettings.ConnectionString); - settings.MaxConnectionPoolSize = 500; - settings.MinConnectionPoolSize = 0; - settings.HeartbeatInterval = TimeSpan.FromSeconds(60); return new MongoClient(settings); } diff --git a/Streetwriters.Identity/Startup.cs b/Streetwriters.Identity/Startup.cs index 9cc4e09..039edfc 100644 --- a/Streetwriters.Identity/Startup.cs +++ b/Streetwriters.Identity/Startup.cs @@ -53,6 +53,7 @@ using Streetwriters.Identity.Interfaces; using Streetwriters.Identity.Jobs; using Streetwriters.Identity.Services; using Streetwriters.Identity.Validation; +using IdentityServer4.MongoDB.Configuration; namespace Streetwriters.Identity { @@ -107,11 +108,6 @@ namespace Streetwriters.Identity options.UsersCollection = "users"; // options.MigrationCollection = "migration"; options.ConnectionString = connectionString; - options.ClusterConfigurator = builder => - { - builder.ConfigureConnectionPool((c) => c.With(maxConnections: 500, minConnections: 0)); - builder.ConfigureServer(s => s.With(heartbeatInterval: TimeSpan.FromSeconds(60))); - }; }).AddDefaultTokenProviders(); services.AddIdentityServer( @@ -137,6 +133,11 @@ namespace Streetwriters.Identity .AddKeyManagement() .AddFileSystemPersistence(Path.Combine(WebHostEnvironment.ContentRootPath, @"keystore")); + services.Configure(options => + { + options.ConnectionString = connectionString; + }); + services.Configure(options => { options.TokenLifespan = TimeSpan.FromHours(2);