feat(backend): add option to disable postgres connection pooling
This commit is contained in:
parent
8054d68f79
commit
2323810b06
3 changed files with 4 additions and 0 deletions
|
@ -36,6 +36,7 @@ public class Config
|
||||||
public class DatabaseConfig
|
public class DatabaseConfig
|
||||||
{
|
{
|
||||||
public string Url { get; init; } = string.Empty;
|
public string Url { get; init; } = string.Empty;
|
||||||
|
public bool? EnablePooling { get; init; }
|
||||||
public int? Timeout { get; init; }
|
public int? Timeout { get; init; }
|
||||||
public int? MaxPoolSize { get; init; }
|
public int? MaxPoolSize { get; init; }
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public class DatabaseContext : DbContext
|
||||||
{
|
{
|
||||||
var connString = new NpgsqlConnectionStringBuilder(config.Database.Url)
|
var connString = new NpgsqlConnectionStringBuilder(config.Database.Url)
|
||||||
{
|
{
|
||||||
|
Pooling = config.Database.EnablePooling ?? true,
|
||||||
Timeout = config.Database.Timeout ?? 5,
|
Timeout = config.Database.Timeout ?? 5,
|
||||||
MaxPoolSize = config.Database.MaxPoolSize ?? 50,
|
MaxPoolSize = config.Database.MaxPoolSize ?? 50,
|
||||||
MinPoolSize = 0,
|
MinPoolSize = 0,
|
||||||
|
|
|
@ -30,6 +30,8 @@ MetricsPort = 5001
|
||||||
[Database]
|
[Database]
|
||||||
; The database URL in ADO.NET format.
|
; The database URL in ADO.NET format.
|
||||||
Url = "Host=localhost;Database=foxnouns_net;Username=pronouns;Password=pronouns"
|
Url = "Host=localhost;Database=foxnouns_net;Username=pronouns;Password=pronouns"
|
||||||
|
; Whether to enable connection pooling. This should be turned off if using pgbouncer. Defaults to true.
|
||||||
|
EnablePooling = true
|
||||||
; The timeout for opening new connections. Defaults to 5.
|
; The timeout for opening new connections. Defaults to 5.
|
||||||
Timeout = 5
|
Timeout = 5
|
||||||
; The maximum number of open connections. Defaults to 50.
|
; The maximum number of open connections. Defaults to 50.
|
||||||
|
|
Loading…
Reference in a new issue