-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Description:
Establish a reliable connection to a PostgreSQL database using the sqlx library. This setup will utilize a connection pool for efficient database interactions and ensure the application can gracefully manage connections.
Requirements:
• Connection Pool Configuration: Implement a connection pool that dynamically manages database connections, optimizing performance and resource utilization.
• Environment Variable: The database connection URL must be securely loaded from environment variables, specifically using DATABASE_URL. This allows for flexibility across different environments, such as development, testing, and production.
Acceptance Criteria:
- Environment Variable Loading: Ensure the application correctly retrieves the
DATABASE_URLfrom the environment. Provide a mechanism to handle cases where the variable is absent or incorrectly formatted, including appropriate error messages. - Connection Pool Initialization: The connection pool must be fully initialized during the application startup sequence to ensure availability when handling requests. Document any necessary middleware or configuration steps required for this process.
- Health Check Endpoint: Implement an endpoint that verifies the validity of the database connection. The endpoint should return:
• Status Code 200 (OK) if the connection to the database is active and valid.
• Relevant Error Codes (e.g., 500 Internal Server Error) if the connection fails, along with an informative message to aid debugging. - Testing: Conduct tests to ensure:
• The connection pool behaves as expected under load.
• The health check functionality consistently reports accurate connection statuses.
Metadata
Metadata
Assignees
Labels
No labels