Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved database management and RabbitMQ connection #1

Merged
merged 9 commits into from
Jun 23, 2024

Conversation

NathaelB
Copy link
Contributor

This pull request brings a number of improvements to database management and the RabbitMQ connection.

The aim is to simplify the initialisation of the creation of the Postgres and RabbitMQ client.
In addition, Clap is used to manage environment variables easily and cleanly.

The creation of a HealthCheck was designed to meet the needs of a native cloud application.

To avoid duplicating data, the use of Arc has been designed to share the references of the Rabbit client and Postgres in a protected way.

NathaelB added 9 commits June 23, 2024 01:23
This commit adds a new file `env.rs` which defines a struct `Env` for storing RabbitMQ configuration. The struct includes fields for `rabbitmq_url`, `rabbitmq_password`, `rabbitmq_user`, and `rabbitmq_port`, all of which are read from environment variables using the `clap` crate.

Recent user commits:
- chore: Update dependencies in Cargo.toml
- chore: Initialize project with basic structure and configuration files

Recent repository commits:
- chore: Update dependencies in Cargo.toml
- chore: Initialize project with basic structure and configuration files
This commit adds a new file `lapin.rs` which defines a struct `LapinClient` for connecting to RabbitMQ. The `LapinClient` struct includes fields for the RabbitMQ connection and channel. It also implements a `new` method for creating a new instance of `LapinClient` with the provided host, port, and credentials.
This commit adds the `health_controller.rs` and `health_service.rs` files, which contain the implementation of the health endpoint for the application. The `health_controller.rs` file defines two routes: `/health/live` and `/health/readiness`, which return the health status of the application and the database respectively. The `health_service.rs` file contains the `HealthService` struct, which is responsible for checking the health of the database. These changes are necessary to ensure the application can properly handle health checks.
This commit adds the `database.rs` file, which contains the implementation of the `Database` struct for connecting to a PostgreSQL database. The `Database` struct includes a `PgPool` field for managing the database connection pool. The `new` method is implemented to create a new instance of `Database` with the provided database configuration. This module is necessary for interacting with the PostgreSQL database in the application.

Recent user commits:
- feat: Add environment struct for storing PostgreSQL configuration
- chore: Update .gitignore and Cargo.lock
- feat: Add health controller and service
- feat: Add LapinClient struct for connecting to RabbitMQ
- feat: Add environment struct for storing RabbitMQ configuration

Recent repository commits:
- chore: Update dependencies in Cargo.toml
- chore: Initialize project with basic structure and configuration files
The code changes add a new file `database.rs` that implements the `Database` struct. This struct is responsible for connecting to a PostgreSQL database and includes a `PgPool` field for managing the database connection pool. The `new` method is implemented to create a new instance of `Database` with the provided database configuration. This addition is necessary for interacting with the PostgreSQL database in the application.
@NathaelB NathaelB merged commit 53a0eb1 into main Jun 23, 2024
@NathaelB NathaelB deleted the enhancement/lapin-and-postgres branch June 23, 2024 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant