From 18ac9f882d7d4c58ab9a66f0a881d783863c3adf Mon Sep 17 00:00:00 2001 From: Ske Date: Wed, 9 Sep 2020 22:21:46 +0200 Subject: [PATCH] Add in-app connection string settings --- PluralKit.Core/Database/Database.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/PluralKit.Core/Database/Database.cs b/PluralKit.Core/Database/Database.cs index e43c9966..0bc88ad1 100644 --- a/PluralKit.Core/Database/Database.cs +++ b/PluralKit.Core/Database/Database.cs @@ -25,6 +25,7 @@ namespace PluralKit.Core private readonly ILogger _logger; private readonly IMetrics _metrics; private readonly DbConnectionCountHolder _countHolder; + private readonly string _connectionString; public Database(CoreConfig config, DbConnectionCountHolder countHolder, ILogger logger, IMetrics metrics) @@ -33,6 +34,11 @@ namespace PluralKit.Core _countHolder = countHolder; _metrics = metrics; _logger = logger; + + _connectionString = new NpgsqlConnectionStringBuilder(_config.Database) + { + Pooling = true, MaxPoolSize = 500, Enlist = false, NoResetOnClose = true + }.ConnectionString; } public static void InitStatic() @@ -76,7 +82,7 @@ namespace PluralKit.Core // Create a connection and open it // We wrap it in PKConnection for tracing purposes - var conn = new PKConnection(new NpgsqlConnection(_config.Database), _countHolder, _logger, _metrics); + var conn = new PKConnection(new NpgsqlConnection(_connectionString), _countHolder, _logger, _metrics); await conn.OpenAsync(); return conn; }