Path: redb-route/redb.Route.Sql/Connection/SqlConnectionOptions.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Sql/Connection/SqlConnectionOptions.cs
----
namespace redb.Route.Sql.Connection;
///
/// Configuration options for a named data source connection.
///
public sealed class SqlConnectionOptions
{
/// Primary connection string (used for writes and default reads).
public string ConnectionString { get; set; } = string.Empty;
///
/// Read replica connection string. Used only by endpoints with readOnly=true ();
/// every other statement, and every statement when this is not set, goes through .
///
public string? ReadConnectionString { get; set; }
///
/// ADO.NET provider invariant name (e.g. "Microsoft.Data.SqlClient", "Npgsql", "MySqlConnector").
/// Used to resolve from the provider registry.
///
public string ProviderName { get; set; } = string.Empty;
///
/// Explicit instance.
/// Takes priority over if both are set.
///
public System.Data.Common.DbProviderFactory? ProviderFactory { get; set; }
/// Minimum connection pool size. Default: 0 (provider default).
public int MinPoolSize { get; set; }
/// Maximum connection pool size. Default: 100.
public int MaxPoolSize { get; set; } = 100;
/// Maximum lifetime of a connection. Default: (unlimited).
public TimeSpan ConnectionLifetime { get; set; } = TimeSpan.Zero;
/// Idle timeout before a pooled connection is closed. Default: 5 minutes.
public TimeSpan ConnectionIdleTimeout { get; set; } = TimeSpan.FromMinutes(5);
/// Validate connection on checkout from pool. Default: false.
public bool TestOnBorrow { get; set; }
/// SQL used to validate a connection. Default: "SELECT 1".
public string ValidationQuery { get; set; } = "SELECT 1";
/// Timeout for validation query in seconds. Default: 5.
public int ValidationTimeout { get; set; } = 5;
/// Timeout for establishing a new connection in seconds. Default: 15.
public int ConnectTimeout { get; set; } = 15;
/// Default command execution timeout in seconds. Default: 30.
public int CommandTimeout { get; set; } = 30;
/// Number of retry attempts for transient failures. Default: 0 (no retry).
public int MaxRetries { get; set; }
/// Delay between retry attempts. Default: 1 second.
public TimeSpan RetryDelay { get; set; } = TimeSpan.FromSeconds(1);
/// Enable automatic retry on transient failures. Default: false.
public bool EnableRetryOnFailure { get; set; }
}