-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHostedStreamingJobMaintenanceService.cs
43 lines (38 loc) · 1.59 KB
/
HostedStreamingJobMaintenanceService.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Threading;
using System.Threading.Tasks;
using Akka.Streams;
using Arcane.Operator.Services.Base;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace Arcane.Operator.Services.Maintenance;
public class HostedStreamingJobMaintenanceService : BackgroundService
{
private readonly ILogger<HostedStreamingJobMaintenanceService> logger;
private readonly IMaterializer materializer;
private readonly IStreamingJobMaintenanceService streamingJobMaintenanceService;
public HostedStreamingJobMaintenanceService(
ILogger<HostedStreamingJobMaintenanceService> logger,
IStreamingJobMaintenanceService streamingJobMaintenanceService,
IMaterializer materializer)
{
this.logger = logger;
this.streamingJobMaintenanceService = streamingJobMaintenanceService;
this.materializer = materializer;
}
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
{
this.logger.LogInformation("Activated {service}", nameof(HostedStreamingJobMaintenanceService));
while (!stoppingToken.IsCancellationRequested)
{
this.logger.LogInformation("Activated JobEventGraph");
await this.streamingJobMaintenanceService
.GetJobEventsGraph(stoppingToken)
.Run(this.materializer);
}
}
public override Task StopAsync(CancellationToken cancellationToken)
{
this.logger.LogInformation("Stopping {service}", nameof(HostedStreamingJobMaintenanceService));
return base.StopAsync(cancellationToken);
}
}