mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-21 13:54:36 +00:00
Modify DataRetention behavior; simplify SQL config
This commit is contained in:
parent
9667820df4
commit
1e8b47784d
2 changed files with 3 additions and 6 deletions
|
@ -15,7 +15,7 @@ namespace BirthdayBot.BackgroundServices
|
||||||
/// </summary>
|
/// </summary>
|
||||||
class DataRetention : BackgroundService
|
class DataRetention : BackgroundService
|
||||||
{
|
{
|
||||||
private static readonly SemaphoreSlim _updateLock = new SemaphoreSlim(1);
|
private static readonly SemaphoreSlim _updateLock = new SemaphoreSlim(2);
|
||||||
const int ProcessInterval = 600 / ShardBackgroundWorker.Interval; // Process every ~10 minutes
|
const int ProcessInterval = 600 / ShardBackgroundWorker.Interval; // Process every ~10 minutes
|
||||||
private int _tickCount = 0;
|
private int _tickCount = 0;
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace BirthdayBot.BackgroundServices
|
||||||
// to avoid putting pressure on the SQL connection pool. Updating this is a low priority.
|
// to avoid putting pressure on the SQL connection pool. Updating this is a low priority.
|
||||||
await _updateLock.WaitAsync(token).ConfigureAwait(false);
|
await _updateLock.WaitAsync(token).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (OperationCanceledException)
|
catch (Exception ex) when (ex is OperationCanceledException || ex is ObjectDisposedException)
|
||||||
{
|
{
|
||||||
// Calling thread does not expect the exception that SemaphoreSlim throws...
|
// Calling thread does not expect the exception that SemaphoreSlim throws...
|
||||||
throw new TaskCanceledException();
|
throw new TaskCanceledException();
|
||||||
|
|
|
@ -58,10 +58,7 @@ namespace BirthdayBot
|
||||||
{
|
{
|
||||||
Host = sqlhost,
|
Host = sqlhost,
|
||||||
Username = sqluser,
|
Username = sqluser,
|
||||||
Password = sqlpass,
|
Password = sqlpass
|
||||||
// Note: Npgsql connection pooling settings are defined (hardcoded) here.
|
|
||||||
MinPoolSize = 3,
|
|
||||||
MaxPoolSize = 20
|
|
||||||
};
|
};
|
||||||
var sqldb = jc["SqlDatabase"]?.Value<string>();
|
var sqldb = jc["SqlDatabase"]?.Value<string>();
|
||||||
if (sqldb != null) csb.Database = sqldb; // Optional database setting
|
if (sqldb != null) csb.Database = sqldb; // Optional database setting
|
||||||
|
|
Loading…
Reference in a new issue