Some checks failed
Docs CI / lint-and-preview (push) Has been cancelled
Notify Smoke Test / Notifier Service Tests (push) Has been cancelled
Notify Smoke Test / Notification Smoke Test (push) Has been cancelled
Notify Smoke Test / Notify Unit Tests (push) Has been cancelled
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Export Center CI / export-ci (push) Has been cancelled
Manifest Integrity / Validate Schema Integrity (push) Has been cancelled
Manifest Integrity / Validate Contract Documents (push) Has been cancelled
Manifest Integrity / Validate Pack Fixtures (push) Has been cancelled
Manifest Integrity / Audit SHA256SUMS Files (push) Has been cancelled
Manifest Integrity / Verify Merkle Roots (push) Has been cancelled
Policy Lint & Smoke / policy-lint (push) Has been cancelled
Risk Bundle CI / risk-bundle-build (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Risk Bundle CI / risk-bundle-offline-kit (push) Has been cancelled
Risk Bundle CI / publish-checksums (push) Has been cancelled
Scanner Analyzers / Build Analyzers (push) Has been cancelled
Scanner Analyzers / Test Language Analyzers (push) Has been cancelled
Scanner Analyzers / Verify Deterministic Output (push) Has been cancelled
devportal-offline / build-offline (push) Has been cancelled
Mirror Thin Bundle Sign & Verify / mirror-sign (push) Has been cancelled
73 lines
3.1 KiB
C#
73 lines
3.1 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
using Microsoft.Extensions.Logging;
|
|
using StellaOps.AirGap.Policy;
|
|
using StellaOps.Notifier.Worker.Channels;
|
|
using StellaOps.Notify.Engine;
|
|
using StellaOps.Notify.Queue;
|
|
using StellaOps.Notify.Storage.Postgres;
|
|
using StellaOps.Notifier.Worker.Storage;
|
|
using StellaOps.Notifier.Worker.Dispatch;
|
|
using StellaOps.Notifier.Worker.Options;
|
|
using StellaOps.Notifier.Worker.Processing;
|
|
using StellaOps.Notifier.Worker.Templates;
|
|
|
|
var builder = Host.CreateApplicationBuilder(args);
|
|
|
|
builder.Configuration
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
.AddEnvironmentVariables(prefix: "NOTIFIER_");
|
|
|
|
builder.Logging.ClearProviders();
|
|
builder.Logging.AddSimpleConsole(options =>
|
|
{
|
|
options.TimestampFormat = "yyyy-MM-ddTHH:mm:ss.fffZ ";
|
|
options.UseUtcTimestamp = true;
|
|
});
|
|
|
|
builder.Services.Configure<NotifierWorkerOptions>(builder.Configuration.GetSection("notifier:worker"));
|
|
builder.Services.AddSingleton(TimeProvider.System);
|
|
|
|
var postgresSection = builder.Configuration.GetSection("notifier:storage:postgres");
|
|
builder.Services.AddNotifyPostgresStorage(builder.Configuration, postgresSection.Path);
|
|
|
|
builder.Services.AddAirGapEgressPolicy(builder.Configuration);
|
|
|
|
builder.Services.AddNotifyEventQueue(builder.Configuration, "notifier:queue");
|
|
builder.Services.AddHealthChecks().AddNotifyQueueHealthCheck();
|
|
|
|
// In-memory storage replacements (document store removed)
|
|
builder.Services.AddSingleton<INotifyChannelRepository, InMemoryNotifyRepositories>();
|
|
builder.Services.AddSingleton<INotifyRuleRepository, InMemoryNotifyRepositories>();
|
|
builder.Services.AddSingleton<INotifyTemplateRepository, InMemoryNotifyRepositories>();
|
|
builder.Services.AddSingleton<INotifyDeliveryRepository, InMemoryNotifyRepositories>();
|
|
builder.Services.AddSingleton<INotifyAuditRepository, InMemoryNotifyRepositories>();
|
|
builder.Services.AddSingleton<INotifyLockRepository, InMemoryNotifyRepositories>();
|
|
builder.Services.AddSingleton<IInAppInboxStore, InMemoryInboxStore>();
|
|
|
|
builder.Services.AddSingleton<INotifyRuleEvaluator, DefaultNotifyRuleEvaluator>();
|
|
builder.Services.AddSingleton<NotifierEventProcessor>();
|
|
builder.Services.AddHostedService<NotifierEventWorker>();
|
|
|
|
// Template service (versioning, localization, redaction)
|
|
builder.Services.AddTemplateServices(options =>
|
|
{
|
|
var provenanceUrl = builder.Configuration["notifier:provenance:baseUrl"];
|
|
if (!string.IsNullOrWhiteSpace(provenanceUrl))
|
|
{
|
|
options.ProvenanceBaseUrl = provenanceUrl;
|
|
}
|
|
});
|
|
|
|
// Dispatch/rendering services
|
|
builder.Services.AddHttpClient<WebhookChannelDispatcher>(client =>
|
|
{
|
|
client.Timeout = TimeSpan.FromSeconds(30);
|
|
client.DefaultRequestHeaders.Add("User-Agent", "StellaOps-Notifier/1.0");
|
|
});
|
|
builder.Services.AddScoped<INotifyChannelDispatcher, WebhookChannelDispatcher>();
|
|
builder.Services.AddHostedService<DeliveryDispatchWorker>();
|
|
|
|
await builder.Build().RunAsync().ConfigureAwait(false);
|