Files
git.stella-ops.org/src/Notify/__Libraries/StellaOps.Notify.Storage.Postgres/ServiceCollectionExtensions.cs
StellaOps Bot 233873f620
Some checks failed
Docs CI / lint-and-preview (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
AOC Guard CI / aoc-guard (push) Has been cancelled
AOC Guard CI / aoc-verify (push) Has been cancelled
Reachability Corpus Validation / validate-corpus (push) Has been cancelled
Reachability Corpus Validation / validate-ground-truths (push) Has been cancelled
Scanner Analyzers / Discover Analyzers (push) Has been cancelled
Scanner Analyzers / Validate Test Fixtures (push) Has been cancelled
Reachability Corpus Validation / determinism-check (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
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
up
2025-12-14 15:50:38 +02:00

89 lines
4.4 KiB
C#

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using StellaOps.Infrastructure.Postgres;
using StellaOps.Infrastructure.Postgres.Options;
using StellaOps.Notify.Storage.Postgres.Repositories;
namespace StellaOps.Notify.Storage.Postgres;
/// <summary>
/// Extension methods for configuring Notify PostgreSQL storage services.
/// </summary>
public static class ServiceCollectionExtensions
{
/// <summary>
/// Adds Notify PostgreSQL storage services.
/// </summary>
/// <param name="services">Service collection.</param>
/// <param name="configuration">Configuration root.</param>
/// <param name="sectionName">Configuration section name for PostgreSQL options.</param>
/// <returns>Service collection for chaining.</returns>
public static IServiceCollection AddNotifyPostgresStorage(
this IServiceCollection services,
IConfiguration configuration,
string sectionName = "Postgres:Notify")
{
services.Configure<PostgresOptions>(sectionName, configuration.GetSection(sectionName));
services.AddSingleton<NotifyDataSource>();
// Register repositories
services.AddScoped<IChannelRepository, ChannelRepository>();
services.AddScoped<IDeliveryRepository, DeliveryRepository>();
services.AddScoped<IRuleRepository, RuleRepository>();
services.AddScoped<ITemplateRepository, TemplateRepository>();
services.AddScoped<IDigestRepository, DigestRepository>();
services.AddScoped<IQuietHoursRepository, QuietHoursRepository>();
services.AddScoped<IMaintenanceWindowRepository, MaintenanceWindowRepository>();
services.AddScoped<IEscalationPolicyRepository, EscalationPolicyRepository>();
services.AddScoped<IEscalationStateRepository, EscalationStateRepository>();
services.AddScoped<IOnCallScheduleRepository, OnCallScheduleRepository>();
services.AddScoped<IInboxRepository, InboxRepository>();
services.AddScoped<IIncidentRepository, IncidentRepository>();
services.AddScoped<INotifyAuditRepository, NotifyAuditRepository>();
services.AddScoped<ILockRepository, LockRepository>();
// Register new repositories (SPRINT-3412: PostgreSQL durability)
services.AddScoped<IThrottleConfigRepository, ThrottleConfigRepository>();
services.AddScoped<IOperatorOverrideRepository, OperatorOverrideRepository>();
services.AddScoped<ILocalizationBundleRepository, LocalizationBundleRepository>();
return services;
}
/// <summary>
/// Adds Notify PostgreSQL storage services with explicit options.
/// </summary>
/// <param name="services">Service collection.</param>
/// <param name="configureOptions">Options configuration action.</param>
/// <returns>Service collection for chaining.</returns>
public static IServiceCollection AddNotifyPostgresStorage(
this IServiceCollection services,
Action<PostgresOptions> configureOptions)
{
services.Configure(configureOptions);
services.AddSingleton<NotifyDataSource>();
// Register repositories
services.AddScoped<IChannelRepository, ChannelRepository>();
services.AddScoped<IDeliveryRepository, DeliveryRepository>();
services.AddScoped<IRuleRepository, RuleRepository>();
services.AddScoped<ITemplateRepository, TemplateRepository>();
services.AddScoped<IDigestRepository, DigestRepository>();
services.AddScoped<IQuietHoursRepository, QuietHoursRepository>();
services.AddScoped<IMaintenanceWindowRepository, MaintenanceWindowRepository>();
services.AddScoped<IEscalationPolicyRepository, EscalationPolicyRepository>();
services.AddScoped<IEscalationStateRepository, EscalationStateRepository>();
services.AddScoped<IOnCallScheduleRepository, OnCallScheduleRepository>();
services.AddScoped<IInboxRepository, InboxRepository>();
services.AddScoped<IIncidentRepository, IncidentRepository>();
services.AddScoped<INotifyAuditRepository, NotifyAuditRepository>();
// Register new repositories (SPRINT-3412: PostgreSQL durability)
services.AddScoped<IThrottleConfigRepository, ThrottleConfigRepository>();
services.AddScoped<IOperatorOverrideRepository, OperatorOverrideRepository>();
services.AddScoped<ILocalizationBundleRepository, LocalizationBundleRepository>();
return services;
}
}