Skip to content

Commit

Permalink
chore: utils chnages
Browse files Browse the repository at this point in the history
  • Loading branch information
shawakash committed Aug 3, 2024
1 parent 4e90173 commit ebdad8c
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions crates/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ diesel = { version = "2.2.0", features = ["postgres", "chrono", "r2d2", "uuid"]
dotenvy = "0.15"
chrono = { version = "0.4.19", features = ["serde"] }
uuid = { version = "1.10.0", features = ["v4", "serde"] }
r2d2_redis = "0.14.0"
2 changes: 2 additions & 0 deletions crates/common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
pub mod redis;
pub mod types;
pub mod utils;
12 changes: 12 additions & 0 deletions crates/common/src/redis.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use r2d2_redis::{r2d2, RedisConnectionManager};
use std::env;

pub type RedisPool = r2d2::Pool<RedisConnectionManager>;

pub fn initialize_redis_pool() -> RedisPool {
let redis_url = env::var("REDIS_URL").expect("REDIS_URL must be set");
let manager = RedisConnectionManager::new(redis_url).unwrap();
r2d2::Pool::builder()
.build(manager)
.expect("Failed to create pool")
}

0 comments on commit ebdad8c

Please sign in to comment.