Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Concelier Attestation Tests / attestation-tests (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Notify Smoke Test / Notify Unit Tests (push) Has been cancelled
Notify Smoke Test / Notifier Service Tests (push) Has been cancelled
Notify Smoke Test / Notification Smoke Test (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
Signals CI & Image / signals-ci (push) Has been cancelled
Signals Reachability Scoring & Events / reachability-smoke (push) Has been cancelled
Signals Reachability Scoring & Events / sign-and-upload (push) Has been cancelled
54 lines
1.8 KiB
C#
54 lines
1.8 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using StellaOps.DependencyInjection;
|
|
using StellaOps.Concelier.Core.Jobs;
|
|
using StellaOps.Concelier.Connector.Ru.Nkcki.Configuration;
|
|
|
|
namespace StellaOps.Concelier.Connector.Ru.Nkcki;
|
|
|
|
public sealed class RuNkckiDependencyInjectionRoutine : IDependencyInjectionRoutine
|
|
{
|
|
private const string ConfigurationSection = "concelier:sources:ru-nkcki";
|
|
|
|
public IServiceCollection Register(IServiceCollection services, IConfiguration configuration)
|
|
{
|
|
ArgumentNullException.ThrowIfNull(services);
|
|
ArgumentNullException.ThrowIfNull(configuration);
|
|
|
|
services.AddRuNkckiConnector(options =>
|
|
{
|
|
configuration.GetSection(ConfigurationSection).Bind(options);
|
|
options.Validate();
|
|
});
|
|
|
|
services.AddTransient<RuNkckiFetchJob>();
|
|
services.AddTransient<RuNkckiParseJob>();
|
|
services.AddTransient<RuNkckiMapJob>();
|
|
|
|
services.PostConfigure<JobSchedulerOptions>(options =>
|
|
{
|
|
EnsureJob(options, RuNkckiJobKinds.Fetch, typeof(RuNkckiFetchJob));
|
|
EnsureJob(options, RuNkckiJobKinds.Parse, typeof(RuNkckiParseJob));
|
|
EnsureJob(options, RuNkckiJobKinds.Map, typeof(RuNkckiMapJob));
|
|
});
|
|
|
|
return services;
|
|
}
|
|
|
|
private static void EnsureJob(JobSchedulerOptions schedulerOptions, string kind, Type jobType)
|
|
{
|
|
if (schedulerOptions.Definitions.ContainsKey(kind))
|
|
{
|
|
return;
|
|
}
|
|
|
|
schedulerOptions.Definitions[kind] = new JobDefinition(
|
|
kind,
|
|
jobType,
|
|
schedulerOptions.DefaultTimeout,
|
|
schedulerOptions.DefaultLeaseDuration,
|
|
CronExpression: null,
|
|
Enabled: true);
|
|
}
|
|
}
|