using System; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using StellaOps.Concelier.Core.Jobs; namespace StellaOps.Concelier.Exporter.Json; public sealed class JsonExportJob : IJob { public const string JobKind = "export:json"; public static readonly TimeSpan DefaultTimeout = TimeSpan.FromMinutes(10); public static readonly TimeSpan DefaultLeaseDuration = TimeSpan.FromMinutes(5); private readonly JsonFeedExporter _exporter; private readonly ILogger _logger; public JsonExportJob(JsonFeedExporter exporter, ILogger logger) { _exporter = exporter ?? throw new ArgumentNullException(nameof(exporter)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); } public async Task ExecuteAsync(JobExecutionContext context, CancellationToken cancellationToken) { _logger.LogInformation("Executing JSON export job {RunId}", context.RunId); await _exporter.ExportAsync(context.Services, cancellationToken).ConfigureAwait(false); _logger.LogInformation("Completed JSON export job {RunId}", context.RunId); } }