Raxol.Database.ConnectionManager (Raxol v0.2.0)
View SourceManages database connections and provides retry logic for Postgres errors.
This module:
- Handles graceful connection retries
- Monitors database connection health
- Provides tools for debugging connection issues
Summary
Functions
Ensures the database connection is reset after application crash.
Checks if the database connection is healthy.
Forcibly restarts the database connection.
Attempts a database operation with retry logic.
Functions
@spec ensure_connection() :: :ok
Ensures the database connection is reset after application crash.
This function should be called during application startup.
@spec healthy?() :: boolean()
Checks if the database connection is healthy.
Returns
true
- Connection is healthyfalse
- Connection is unhealthy
@spec restart_connection() :: :ok
Forcibly restarts the database connection.
Attempts a database operation with retry logic.
Parameters
operation
- A function that performs a database operationmax_retries
- Maximum number of retry attempts (default: 5)retry_delay_ms
- Delay between retries in milliseconds (default: 1000)
Returns
{:ok, result}
- Operation succeeded{:error, error}
- Operation failed after retries