[backend/database] Add connection pool size configuration option

This commit is contained in:
Laura Hausmann 2024-04-27 20:05:42 +02:00
parent bc1e695193
commit 0b77107b1e
No known key found for this signature in database
GPG key ID: D044E84C5BE01605
3 changed files with 15 additions and 10 deletions

View file

@ -73,6 +73,7 @@ public sealed class Config
[Required] public string Database { get; init; } = null!;
[Required] public string Username { get; init; } = null!;
public string? Password { get; init; }
[Range(1, 1000)] public int MaxConnections { get; init; } = 100;
}
public sealed class StorageSection

View file

@ -103,6 +103,7 @@ public class DatabaseContext(DbContextOptions<DatabaseContext> options)
dataSourceBuilder.ConnectionStringBuilder.Username = config.Username;
dataSourceBuilder.ConnectionStringBuilder.Password = config.Password;
dataSourceBuilder.ConnectionStringBuilder.Database = config.Database;
dataSourceBuilder.ConnectionStringBuilder.MaxPoolSize = config.MaxConnections;
return ConfigureDataSource(dataSourceBuilder);
}

View file

@ -66,6 +66,9 @@ Database = iceshrimp
Username = iceshrimp
Password = iceshrimp
;; The maximum amount of connections for the connection pool. Valid range: 1-1000. Defaults to 100 if unset.
MaxConnections = 100
[Storage]
;; Where to store media attachments
;; Options: [Local, ObjectStorage]