feat: begin working on Onspring worker

This commit is contained in:
Stevan Freeborn
2024-08-26 15:26:16 -05:00
parent 9e9bafa226
commit 836c24f4d1
9 changed files with 148 additions and 1 deletions
@@ -17,7 +17,7 @@ public class DatabaseWorker(
await UpdateDatabase();
using var scope = _serviceScopeFactory.CreateScope();
using var scope = _serviceScopeFactory.CreateAsyncScope();
var dbOptions = scope.ServiceProvider.GetRequiredService<DbOptions>();
_timer = _timeProvider.CreateTimer(
@@ -40,10 +40,14 @@ public class DatabaseWorker(
public void Dispose()
{
_timer?.Dispose();
GC.SuppressFinalize(this);
}
private async Task UpdateDatabase()
{
var updateIdProperty = LogContext.PushProperty("DatabaseUpdateId", Guid.NewGuid());
_logger.LogInformation("Updating database");
try
@@ -63,5 +67,9 @@ public class DatabaseWorker(
{
_logger.LogError(ex, "Error updating database");
}
finally
{
updateIdProperty.Dispose();
}
}
}