Add in-app connection string settings

This commit is contained in:
Ske 2020-09-09 22:21:46 +02:00
parent 47bdc34142
commit 18ac9f882d

View File

@ -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;
}