You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
929 B
31 lines
929 B
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Kafka2Doris
|
|
{
|
|
public class Worker : BackgroundService
|
|
{
|
|
private readonly ILogger<Worker> _logger;
|
|
private readonly IConfiguration _config;
|
|
|
|
public Worker(ILogger<Worker> logger, IConfiguration config)
|
|
{
|
|
this._logger = logger;
|
|
this._config = config;
|
|
}
|
|
|
|
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
|
|
{
|
|
while (!stoppingToken.IsCancellationRequested)
|
|
{
|
|
_logger.LogInformation("Worker running at: {time}", DateTimeOffset.Now);
|
|
//读取kafka
|
|
await Task.Delay(this._config.GetValue("delay", 1000 * 60), stoppingToken);
|
|
}
|
|
}
|
|
}
|
|
} |