Skip to content

Commit 5552d09

Browse files
authored
Merge pull request #251 from AelfScanProject/hotfix/worker-period-option
feat: support configurable Period for LogEventDelWorker via options
2 parents 79e7beb + 81ad774 commit 5552d09

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,27 @@
11
using System.Threading.Tasks;
2+
using AElfScanServer.Worker.Core.Options;
23
using AElfScanServer.Worker.Core.Service;
34
using Microsoft.Extensions.DependencyInjection;
45
using Microsoft.Extensions.Logging;
6+
using Microsoft.Extensions.Options;
57
using Volo.Abp.BackgroundWorkers;
68
using Volo.Abp.Threading;
7-
89
namespace AElfScanServer.Worker.Core.Worker;
9-
1010
public class LogEventDelWorker : AsyncPeriodicBackgroundWorkerBase
1111
{
1212
private readonly ITransactionService _transactionService;
13-
1413
private readonly ILogger<LogEventDelWorker> _logger;
15-
16-
14+
private const string WorkerName = "LogEventDelWorker";
1715
public LogEventDelWorker(AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory,
18-
ILogger<LogEventDelWorker> logger, ITransactionService transactionService) : base(timer,
16+
ILogger<LogEventDelWorker> logger, ITransactionService transactionService, IOptionsMonitor<WorkerOptions> workerOptions) : base(timer,
1917
serviceScopeFactory)
2018
{
21-
timer.Period = 1000 * 60 * 15;
19+
timer.Period = workerOptions.CurrentValue.GetWorkerPeriodMinutes(WorkerName) * 60 * 1000;
2220
_logger = logger;
2321
_transactionService = transactionService;
2422
}
25-
2623
protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
2724
{
2825
await _transactionService.DelLogEventTask();
2926
}
30-
}
27+
}

0 commit comments

Comments
 (0)