data: configure mongodb using connection string

This commit is contained in:
Abdullah Atta
2026-02-02 22:33:32 +05:00
parent bf70a32b95
commit 014c4e3b32
2 changed files with 6 additions and 8 deletions

View File

@@ -33,9 +33,6 @@ namespace Streetwriters.Data.DbContexts
public static IMongoClient CreateMongoDbClient(IDbSettings dbSettings) public static IMongoClient CreateMongoDbClient(IDbSettings dbSettings)
{ {
var settings = MongoClientSettings.FromConnectionString(dbSettings.ConnectionString); var settings = MongoClientSettings.FromConnectionString(dbSettings.ConnectionString);
settings.MaxConnectionPoolSize = 500;
settings.MinConnectionPoolSize = 0;
settings.HeartbeatInterval = TimeSpan.FromSeconds(60);
return new MongoClient(settings); return new MongoClient(settings);
} }

View File

@@ -53,6 +53,7 @@ using Streetwriters.Identity.Interfaces;
using Streetwriters.Identity.Jobs; using Streetwriters.Identity.Jobs;
using Streetwriters.Identity.Services; using Streetwriters.Identity.Services;
using Streetwriters.Identity.Validation; using Streetwriters.Identity.Validation;
using IdentityServer4.MongoDB.Configuration;
namespace Streetwriters.Identity namespace Streetwriters.Identity
{ {
@@ -107,11 +108,6 @@ namespace Streetwriters.Identity
options.UsersCollection = "users"; options.UsersCollection = "users";
// options.MigrationCollection = "migration"; // options.MigrationCollection = "migration";
options.ConnectionString = connectionString; 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(); }).AddDefaultTokenProviders();
services.AddIdentityServer( services.AddIdentityServer(
@@ -137,6 +133,11 @@ namespace Streetwriters.Identity
.AddKeyManagement() .AddKeyManagement()
.AddFileSystemPersistence(Path.Combine(WebHostEnvironment.ContentRootPath, @"keystore")); .AddFileSystemPersistence(Path.Combine(WebHostEnvironment.ContentRootPath, @"keystore"));
services.Configure<MongoDBConfiguration>(options =>
{
options.ConnectionString = connectionString;
});
services.Configure<DataProtectionTokenProviderOptions>(options => services.Configure<DataProtectionTokenProviderOptions>(options =>
{ {
options.TokenLifespan = TimeSpan.FromHours(2); options.TokenLifespan = TimeSpan.FromHours(2);