Skip to content

Commit

Permalink
switch back to connection manager from cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Nov 16, 2023
1 parent 75a91be commit abe303c
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 47 deletions.
4 changes: 2 additions & 2 deletions lib/chirp/worker/src/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ where
// Create a dedicated connection to redis-chirp for blocking Redis requests
// that won't block other requests in the pool.
let url = std::env::var("REDIS_URL_PERSISTENT").expect("REDIS_URL_PERSISTENT");
let redis_chirp_conn = redis::cluster::ClusterClient::new(vec![url.as_str()])
let redis_chirp_conn = redis::Client::open(url)
.map_err(ManagerError::BuildRedis)?
.get_async_connection()
.get_tokio_connection_manager()
.await
.map_err(ManagerError::BuildRedis)?;

Expand Down
2 changes: 1 addition & 1 deletion lib/pools/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ version = "0.23"
default-features = false
features = [
"aio",
"cluster-async",
"tokio-comp",
"tokio-native-tls-comp",
"connection-manager",
"script",
"streams",
]
9 changes: 2 additions & 7 deletions lib/pools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,9 @@ async fn redis_from_env() -> Result<HashMap<String, RedisPool>, Error> {
.name("redis_from_env")
.spawn(async move {
tracing::info!(%url, "redis connecting");
let conn = redis::cluster::ClusterClient::builder(vec![url.as_str()])
// Keep trying to reconnect indefinitely
.retries(u32::MAX)
.min_retry_wait(250)
.max_retry_wait(30_000)
.build()
let conn = redis::Client::open(url.as_str())
.map_err(Error::BuildRedis)?
.get_async_connection()
.get_tokio_connection_manager()
.await
.map_err(Error::BuildRedis)?;

Expand Down
29 changes: 1 addition & 28 deletions lib/pools/src/pools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,7 @@ use crate::Error;

pub type NatsPool = async_nats::Client;
pub type CrdbPool = sqlx::PgPool;
pub type RedisPool = redis::cluster_async::ClusterConnection;

// #[derive(Clone)]
// struct RedisPool {
// connection: redis::cluster_async::ClusterConnection,
// }

// impl RedisPool {
// pub async fn pipe<T, F>(&mut self, f: F) -> RedisResult<T> where F: FnOnce(redis::cluster::ClusterPipeline) -> redis::cluster::ClusterPipeline {
// let mut pipe = redis::cluster::cluster_pipe();

// f(pipe);

// thread::spawn(|| async {
// pipe.query(&mut self)
// }).await
// }

// pub async fn cmd<T, F>(&mut self, cmd: &str, f: F) -> RedisResult<T> where F: FnOnce(redis::cluster::ClusterPipeline) -> redis::cluster::ClusterPipeline {
// let mut cmd = redis::cluster::cmd(cmd);

// f(cmd);

// thread::spawn(|| async {
// pipe.query(&mut self)
// }).await
// }
// }
pub type RedisPool = redis::aio::ConnectionManager;

pub type Pools = Arc<PoolsInner>;

Expand Down
9 changes: 0 additions & 9 deletions svc/Cargo.lock

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

0 comments on commit abe303c

Please sign in to comment.