Skip to content

Commit d89d063

Browse files
jaymellsvix-james
authored andcommitted
Rename RedisPool to RedisManager
Now that our redis backends are not always pooled, having `Pool` in the name is sort of confusing, so rename the type to something a bit more generic.
1 parent 5f88c1c commit d89d063

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

server/svix-server/src/core/cache/redis.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ use axum::async_trait;
77
use redis::AsyncCommands as _;
88

99
use super::{Cache, CacheBehavior, CacheKey, Error, Result};
10-
use crate::redis::RedisPool;
10+
use crate::redis::RedisManager;
1111

12-
pub fn new(redis: RedisPool) -> Cache {
12+
pub fn new(redis: RedisManager) -> Cache {
1313
RedisCache { redis }.into()
1414
}
1515

1616
#[derive(Clone)]
1717
pub struct RedisCache {
18-
redis: RedisPool,
18+
redis: RedisManager,
1919
}
2020

2121
#[async_trait]
@@ -112,7 +112,7 @@ mod tests {
112112
}
113113
}
114114

115-
async fn get_pool(redis_dsn: &str, cfg: &crate::cfg::Configuration) -> RedisPool {
115+
async fn get_pool(redis_dsn: &str, cfg: &crate::cfg::Configuration) -> RedisManager {
116116
match cfg.cache_type {
117117
CacheType::RedisCluster => crate::redis::new_redis_clustered_unpooled(redis_dsn).await,
118118
CacheType::Redis => crate::redis::new_redis_unpooled(redis_dsn).await,

server/svix-server/src/queue/redis.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use super::{QueueTask, TaskQueueConsumer, TaskQueueProducer};
3636
use crate::{
3737
cfg::{Configuration, QueueType},
3838
error::Result,
39-
redis::{PooledConnection, RedisPool},
39+
redis::{PooledConnection, RedisManager},
4040
};
4141

4242
/// This is the key of the main queue. As a KV store, redis places the entire stream under this key.
@@ -93,7 +93,7 @@ pub async fn new_pair(
9393
/// Runs Redis queue migrations with the given delay schedule. Migrations are run on this schedule
9494
/// such that if an old instance of the server is online after the migrations are made, that no data
9595
/// will be lost assuming the old server is taken offline before the last scheduled delay.
96-
async fn run_migration_schedule(delays: &[Duration], pool: RedisPool) {
96+
async fn run_migration_schedule(delays: &[Duration], pool: RedisManager) {
9797
let mut conn = pool
9898
.get()
9999
.await
@@ -358,10 +358,10 @@ pub mod tests {
358358
cfg::{Configuration, QueueType},
359359
core::types::{ApplicationId, EndpointId, MessageAttemptTriggerType, MessageId},
360360
queue::{MessageTask, QueueTask, TaskQueueConsumer, TaskQueueProducer},
361-
redis::RedisPool,
361+
redis::RedisManager,
362362
};
363363

364-
async fn get_pool(cfg: &Configuration) -> RedisPool {
364+
async fn get_pool(cfg: &Configuration) -> RedisManager {
365365
match cfg.queue_type {
366366
QueueType::RedisCluster => {
367367
crate::redis::new_redis_clustered_pooled(cfg.redis_dsn.as_deref().unwrap(), cfg)

server/svix-server/src/redis/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ use crate::cfg::Configuration;
1212
pub const REDIS_CONN_TIMEOUT: Duration = Duration::from_secs(2);
1313

1414
#[derive(Clone, Debug)]
15-
pub enum RedisPool {
15+
pub enum RedisManager {
1616
Clustered(ClusteredRedisPool),
1717
ClusteredUnpooled(ClusteredRedisUnpooled),
1818
NonClustered(NonClusteredRedisPool),
1919
NonClusteredUnpooled(NonClusteredRedisUnpooled),
2020
}
2121

22-
impl RedisPool {
22+
impl RedisManager {
2323
pub async fn get(&self) -> Result<PooledConnection<'_>, RunError<RedisError>> {
2424
match self {
2525
Self::Clustered(pool) => pool.get().await,
@@ -234,7 +234,7 @@ async fn new_redis_pool_helper(
234234
redis_dsn: &str,
235235
clustered: bool,
236236
max_connections: u16,
237-
) -> RedisPool {
237+
) -> RedisManager {
238238
if clustered {
239239
let mgr = RedisClusterConnectionManager::new(redis_dsn)
240240
.expect("Error initializing redis cluster client");
@@ -244,7 +244,7 @@ async fn new_redis_pool_helper(
244244
.await
245245
.expect("Error initializing redis cluster connection pool");
246246
let pool = ClusteredRedisPool { pool };
247-
RedisPool::Clustered(pool)
247+
RedisManager::Clustered(pool)
248248
} else {
249249
let mgr = RedisConnectionManager::new(redis_dsn).expect("Error initializing redis client");
250250
let pool = bb8::Pool::builder()
@@ -253,11 +253,11 @@ async fn new_redis_pool_helper(
253253
.await
254254
.expect("Error initializing redis connection pool");
255255
let pool = NonClusteredRedisPool { pool };
256-
RedisPool::NonClustered(pool)
256+
RedisManager::NonClustered(pool)
257257
}
258258
}
259259

260-
async fn new_redis_unpooled_helper(redis_dsn: &str, clustered: bool) -> RedisPool {
260+
async fn new_redis_unpooled_helper(redis_dsn: &str, clustered: bool) -> RedisManager {
261261
if clustered {
262262
let cli = redis::cluster::ClusterClient::builder(vec![redis_dsn])
263263
.retries(1)
@@ -268,7 +268,7 @@ async fn new_redis_unpooled_helper(redis_dsn: &str, clustered: bool) -> RedisPoo
268268
.get_async_connection()
269269
.await
270270
.expect("Failed to get redis-cluster-unpooled connection");
271-
RedisPool::ClusteredUnpooled(ClusteredRedisUnpooled { con })
271+
RedisManager::ClusteredUnpooled(ClusteredRedisUnpooled { con })
272272
} else {
273273
let cli = redis::Client::open(redis_dsn).expect("Error initializing redis unpooled client");
274274
let con = redis::aio::ConnectionManager::new_with_backoff_and_timeouts(
@@ -281,34 +281,34 @@ async fn new_redis_unpooled_helper(redis_dsn: &str, clustered: bool) -> RedisPoo
281281
)
282282
.await
283283
.expect("Failed to get redis-unpooled connection manager");
284-
RedisPool::NonClusteredUnpooled(NonClusteredRedisUnpooled { con })
284+
RedisManager::NonClusteredUnpooled(NonClusteredRedisUnpooled { con })
285285
}
286286
}
287287

288-
pub async fn new_redis_clustered_pooled(redis_dsn: &str, cfg: &Configuration) -> RedisPool {
288+
pub async fn new_redis_clustered_pooled(redis_dsn: &str, cfg: &Configuration) -> RedisManager {
289289
new_redis_pool_helper(redis_dsn, true, cfg.redis_pool_max_size).await
290290
}
291291

292-
pub async fn new_redis_clustered_unpooled(redis_dsn: &str) -> RedisPool {
292+
pub async fn new_redis_clustered_unpooled(redis_dsn: &str) -> RedisManager {
293293
new_redis_unpooled_helper(redis_dsn, true).await
294294
}
295295

296-
pub async fn new_redis_pooled(redis_dsn: &str, cfg: &Configuration) -> RedisPool {
296+
pub async fn new_redis_pooled(redis_dsn: &str, cfg: &Configuration) -> RedisManager {
297297
new_redis_pool_helper(redis_dsn, false, cfg.redis_pool_max_size).await
298298
}
299299

300-
pub async fn new_redis_unpooled(redis_dsn: &str) -> RedisPool {
300+
pub async fn new_redis_unpooled(redis_dsn: &str) -> RedisManager {
301301
new_redis_unpooled_helper(redis_dsn, false).await
302302
}
303303

304304
#[cfg(test)]
305305
mod tests {
306306
use redis::AsyncCommands;
307307

308-
use super::RedisPool;
308+
use super::RedisManager;
309309
use crate::cfg::{CacheType, Configuration};
310310

311-
async fn get_pool(redis_dsn: &str, cfg: &Configuration) -> RedisPool {
311+
async fn get_pool(redis_dsn: &str, cfg: &Configuration) -> RedisManager {
312312
match cfg.cache_type {
313313
CacheType::RedisCluster => super::new_redis_clustered_unpooled(redis_dsn).await,
314314
CacheType::Redis => super::new_redis_unpooled(redis_dsn).await,

server/svix-server/tests/it/redis_queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ use svix_server::{
1313
queue::{
1414
new_pair, MessageTask, QueueTask, TaskQueueConsumer, TaskQueueDelivery, TaskQueueProducer,
1515
},
16-
redis::{new_redis_clustered_pooled, new_redis_pooled, RedisPool},
16+
redis::{new_redis_clustered_pooled, new_redis_pooled, RedisManager},
1717
};
1818

1919
// TODO: Don't copy this from the Redis queue test directly, place the fn somewhere both can access
20-
async fn get_pool(cfg: &Configuration) -> RedisPool {
20+
async fn get_pool(cfg: &Configuration) -> RedisManager {
2121
match cfg.queue_type {
2222
QueueType::RedisCluster => {
2323
new_redis_clustered_pooled(cfg.redis_dsn.as_deref().unwrap(), cfg).await

0 commit comments

Comments
 (0)