feat(Program): make Quartz cron schedule configurable via appsettings

- Replaced hardcoded cron expression with configuration-based `Worker:CronExpression`.
- Throws descriptive exception if cron expression is missing.
- Keeps previous worker and DB context setup unchanged.
This commit is contained in:
Developer 02
2025-11-04 15:37:20 +01:00
parent 0a175b9e9d
commit 75e7e9925b
4 changed files with 13 additions and 29 deletions

View File

@@ -8,21 +8,19 @@ namespace EnvelopeGenerator.Finalizer
{
private readonly ILogger<Worker> _logger;
private readonly WorkerOptions _options;
public Worker(ILogger<Worker> logger, IOptions<WorkerOptions> workerOptions)
public Worker(ILogger<Worker> logger)
{
_logger = logger;
_options = workerOptions.Value;
}
public async Task Execute(IJobExecutionContext context)
public Task Execute(IJobExecutionContext context)
{
if (_logger.IsEnabled(LogLevel.Information))
{
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
}
await Task.Delay(_options.IntervalInMillisecond, context.CancellationToken);
return Task.CompletedTask;
}
}
}