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:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user