Skip to content

Commit

Permalink
fix(rabbitmq): rmq service
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmard committed May 4, 2024
1 parent 33767b3 commit af0d792
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "medullah_web"
version = "0.1.4"
name = "medullah-web"
version = "0.1.5"
edition = "2021"

[features]
Expand Down
7 changes: 4 additions & 3 deletions src/app_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::MEDULLAH;
#[cfg(feature = "feat-rabbitmq")]
use crate::rabbitmq::conn::establish_rabbit_connection;
use crate::redis::conn::{establish_redis_connection, establish_redis_connection_pool};
use crate::services::rabbit_service::RabbitService;

pub async fn make_app_state(env_prefix: String) -> MedullahState {
let app = create_app_state(env_prefix).await;
Expand All @@ -40,7 +41,7 @@ async fn create_app_state(env_prefix: String) -> MedullahState {

// RabbitMQ
#[cfg(feature = "feat-rabbitmq")]
let rabbit = establish_rabbit_connection(&env_prefix).await;
let rabbit = Arc::new(establish_rabbit_connection(&env_prefix).await);

// templating
let tpl_dir = get_cwd() + "/resources/templates/**/*.tera.html";
Expand All @@ -58,7 +59,7 @@ async fn create_app_state(env_prefix: String) -> MedullahState {
redis: Arc::new(redis),
redis_pool: Arc::new(redis_pool),
#[cfg(feature = "feat-rabbitmq")]
rabbit: Arc::new(rabbit),
rabbit: rabbit.clone(),
#[cfg(feature = "feat-database")]
database: database_pool,
tera: tera_templating,
Expand All @@ -85,7 +86,7 @@ async fn create_app_state(env_prefix: String) -> MedullahState {

services: AppServices {
#[cfg(feature = "feat-rabbitmq")]
rabbitmq: rabbit.clone(),
rabbitmq: RabbitService::new(rabbit.clone()),
redis: redis_service.clone(),
cache: Arc::new(CacheService::new(redis_service)),
},
Expand Down
3 changes: 2 additions & 1 deletion src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use tera::{Context, Tera};

use crate::redis::RedisPool;
use crate::services::cache_service::CacheService;
use crate::services::rabbit_service::RabbitService;
use crate::services::redis_service::RedisService;

#[derive(Clone)]
Expand Down Expand Up @@ -47,7 +48,7 @@ pub struct AppServices {
pub redis: Arc<RedisService>,
pub cache: Arc<CacheService>,
#[cfg(feature = "feat-rabbitmq")]
pub rabbitmq: Arc<lapin::Connection>,
pub rabbitmq: Arc<RabbitService>,
}

impl MedullahState {
Expand Down

0 comments on commit af0d792

Please sign in to comment.