49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
// Copyright (c) StellaOps. Licensed under the BUSL-1.1.
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
using Microsoft.Extensions.Options;
|
|
using Npgsql;
|
|
using StellaOps.Infrastructure.Postgres.Connections;
|
|
using StellaOps.Infrastructure.Postgres.Options;
|
|
|
|
namespace StellaOps.Eventing.Postgres;
|
|
|
|
/// <summary>
|
|
/// PostgreSQL data source for the Eventing module.
|
|
/// Manages connections for timeline event storage and outbox processing.
|
|
/// </summary>
|
|
public sealed class EventingDataSource : DataSourceBase
|
|
{
|
|
/// <summary>
|
|
/// Default schema name for Eventing tables.
|
|
/// </summary>
|
|
public const string DefaultSchemaName = "timeline";
|
|
|
|
/// <summary>
|
|
/// Creates a new Eventing data source.
|
|
/// </summary>
|
|
public EventingDataSource(IOptions<PostgresOptions> options, ILogger<EventingDataSource> logger)
|
|
: base(CreateOptions(options.Value), logger)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override string ModuleName => "Eventing";
|
|
|
|
/// <inheritdoc />
|
|
protected override void ConfigureDataSourceBuilder(NpgsqlDataSourceBuilder builder)
|
|
{
|
|
base.ConfigureDataSourceBuilder(builder);
|
|
// No custom enum mappings required for the Eventing module.
|
|
}
|
|
|
|
private static PostgresOptions CreateOptions(PostgresOptions baseOptions)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(baseOptions.SchemaName))
|
|
{
|
|
baseOptions.SchemaName = DefaultSchemaName;
|
|
}
|
|
return baseOptions;
|
|
}
|
|
}
|