up
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
namespace StellaOps.Infrastructure.Postgres.Options;
|
||||
|
||||
/// <summary>
|
||||
/// Persistence backend selection for dual-write/migration scenarios.
|
||||
/// </summary>
|
||||
public enum PersistenceBackend
|
||||
{
|
||||
/// <summary>
|
||||
/// Use MongoDB as the primary backend (legacy).
|
||||
/// </summary>
|
||||
Mongo,
|
||||
|
||||
/// <summary>
|
||||
/// Use PostgreSQL as the primary backend.
|
||||
/// </summary>
|
||||
Postgres,
|
||||
|
||||
/// <summary>
|
||||
/// Dual-write mode: write to both backends, read from primary.
|
||||
/// Used during migration phase for data consistency verification.
|
||||
/// </summary>
|
||||
DualWrite
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Persistence options for module backend selection.
|
||||
/// </summary>
|
||||
public sealed class PersistenceOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Configuration section name.
|
||||
/// </summary>
|
||||
public const string SectionName = "Persistence";
|
||||
|
||||
/// <summary>
|
||||
/// Backend for Authority module.
|
||||
/// </summary>
|
||||
public PersistenceBackend Authority { get; set; } = PersistenceBackend.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// Backend for Scheduler module.
|
||||
/// </summary>
|
||||
public PersistenceBackend Scheduler { get; set; } = PersistenceBackend.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// Backend for Notify module.
|
||||
/// </summary>
|
||||
public PersistenceBackend Notify { get; set; } = PersistenceBackend.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// Backend for Policy module.
|
||||
/// </summary>
|
||||
public PersistenceBackend Policy { get; set; } = PersistenceBackend.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// Backend for Concelier (vulnerability) module.
|
||||
/// </summary>
|
||||
public PersistenceBackend Concelier { get; set; } = PersistenceBackend.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// Backend for Excititor (VEX/graph) module.
|
||||
/// </summary>
|
||||
public PersistenceBackend Excititor { get; set; } = PersistenceBackend.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// In dual-write mode, which backend to read from.
|
||||
/// </summary>
|
||||
public PersistenceBackend DualWriteReadFrom { get; set; } = PersistenceBackend.Mongo;
|
||||
|
||||
/// <summary>
|
||||
/// Enable comparison logging in dual-write mode.
|
||||
/// Logs discrepancies between backends for debugging.
|
||||
/// </summary>
|
||||
public bool DualWriteComparisonLogging { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
namespace StellaOps.Infrastructure.Postgres.Options;
|
||||
|
||||
/// <summary>
|
||||
/// PostgreSQL connection and behavior options.
|
||||
/// </summary>
|
||||
public sealed class PostgresOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// PostgreSQL connection string.
|
||||
/// </summary>
|
||||
public required string ConnectionString { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Command timeout in seconds. Default is 30 seconds.
|
||||
/// </summary>
|
||||
public int CommandTimeoutSeconds { get; set; } = 30;
|
||||
|
||||
/// <summary>
|
||||
/// Maximum number of connections in the pool. Default is 100.
|
||||
/// </summary>
|
||||
public int MaxPoolSize { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// Minimum number of connections in the pool. Default is 1.
|
||||
/// </summary>
|
||||
public int MinPoolSize { get; set; } = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Connection idle lifetime in seconds. Default is 300 seconds (5 minutes).
|
||||
/// </summary>
|
||||
public int ConnectionIdleLifetimeSeconds { get; set; } = 300;
|
||||
|
||||
/// <summary>
|
||||
/// Enable connection pooling. Default is true.
|
||||
/// </summary>
|
||||
public bool Pooling { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Schema name for module-specific tables. If null, uses public schema.
|
||||
/// </summary>
|
||||
public string? SchemaName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Enable automatic migration on startup. Default is false for production safety.
|
||||
/// </summary>
|
||||
public bool AutoMigrate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Path to SQL migration files. Required if AutoMigrate is true.
|
||||
/// </summary>
|
||||
public string? MigrationsPath { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user