Skip to content

Commit 57ef2e5

Browse files
jaymellsvix-james
authored andcommitted
Remove rediscluster cache backend
Note: Also fixed some of the queue tests, which should match based on the _queue_ configuration, not the cache config.
1 parent 00e1fe4 commit 57ef2e5

File tree

7 files changed

+16
-37
lines changed

7 files changed

+16
-37
lines changed

server/svix-server/src/cfg.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ pub struct ConfigurationInner {
193193
fn validate_config_complete(config: &ConfigurationInner) -> Result<(), ValidationError> {
194194
match config.cache_type {
195195
CacheType::None | CacheType::Memory => {}
196-
CacheType::Redis | CacheType::RedisCluster | CacheType::RedisClusterUnpooled => {
196+
CacheType::Redis | CacheType::RedisClusterUnpooled => {
197197
if config.cache_dsn().is_none() {
198198
return Err(ValidationError {
199199
code: Cow::from("missing field"),
@@ -266,7 +266,6 @@ impl ConfigurationInner {
266266
CacheType::None => CacheBackend::None,
267267
CacheType::Memory => CacheBackend::Memory,
268268
CacheType::Redis => CacheBackend::Redis(self.cache_dsn().expect(err)),
269-
CacheType::RedisCluster => CacheBackend::RedisCluster(self.cache_dsn().expect(err)),
270269
CacheType::RedisClusterUnpooled => {
271270
CacheBackend::RedisClusterUnpooled(self.cache_dsn().expect(err))
272271
}
@@ -306,7 +305,6 @@ pub enum CacheBackend<'a> {
306305
None,
307306
Memory,
308307
Redis(&'a str),
309-
RedisCluster(&'a str),
310308
RedisClusterUnpooled(&'a str),
311309
}
312310

@@ -339,7 +337,6 @@ pub enum QueueType {
339337
pub enum CacheType {
340338
Memory,
341339
Redis,
342-
RedisCluster,
343340
RedisClusterUnpooled,
344341
None,
345342
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ mod tests {
114114

115115
async fn get_pool(redis_dsn: &str, cfg: &crate::cfg::Configuration) -> RedisPool {
116116
match cfg.cache_type {
117-
CacheType::RedisCluster => crate::redis::new_redis_pool_clustered(redis_dsn, cfg).await,
118117
CacheType::RedisClusterUnpooled => {
119118
crate::redis::new_redis_clustered_unpooled(redis_dsn).await
120119
}

server/svix-server/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,6 @@ pub async fn run_with_prefix(
113113
let mgr = crate::redis::new_redis_pool(dsn, &cfg).await;
114114
cache::redis::new(mgr)
115115
}
116-
CacheBackend::RedisCluster(dsn) => {
117-
let mgr = crate::redis::new_redis_pool_clustered(dsn, &cfg).await;
118-
cache::redis::new(mgr)
119-
}
120116
CacheBackend::RedisClusterUnpooled(dsn) => {
121117
let mgr = crate::redis::new_redis_clustered_unpooled(dsn).await;
122118
cache::redis::new(mgr)

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,23 +355,20 @@ pub mod tests {
355355

356356
use super::{migrate_list, migrate_list_to_stream, migrate_sset, new_pair_inner};
357357
use crate::{
358-
cfg::{CacheType, Configuration},
358+
cfg::{Configuration, QueueType},
359359
core::types::{ApplicationId, EndpointId, MessageAttemptTriggerType, MessageId},
360360
queue::{MessageTask, QueueTask, TaskQueueConsumer, TaskQueueProducer},
361361
redis::RedisPool,
362362
};
363363

364364
async fn get_pool(cfg: &Configuration) -> RedisPool {
365-
match cfg.cache_type {
366-
CacheType::RedisCluster => {
365+
match cfg.queue_type {
366+
QueueType::RedisCluster => {
367367
crate::redis::new_redis_pool_clustered(cfg.redis_dsn.as_deref().unwrap(), cfg).await
368368
}
369-
CacheType::Redis => {
369+
QueueType::Redis => {
370370
crate::redis::new_redis_pool(cfg.redis_dsn.as_deref().unwrap(), cfg).await
371371
}
372-
CacheType::RedisClusterUnpooled => {
373-
crate::redis::new_redis_clustered_unpooled(cfg.redis_dsn.as_deref().unwrap()).await
374-
}
375372
_ => {
376373
panic!("This test should only be run when redis is configured as the queue backend")
377374
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,6 @@ mod tests {
245245

246246
async fn get_pool(redis_dsn: &str, cfg: &Configuration) -> RedisPool {
247247
match cfg.cache_type {
248-
CacheType::RedisCluster => super::new_redis_pool_clustered(redis_dsn, cfg).await,
249248
CacheType::RedisClusterUnpooled => super::new_redis_clustered_unpooled(redis_dsn).await,
250249
CacheType::Redis => super::new_redis_pool(redis_dsn, cfg).await,
251250
_ => panic!(

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

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use svix_server::{
1212
message_app::AppEndpointKey,
1313
types::{BaseId, OrganizationId},
1414
},
15-
redis::{new_redis_clustered_unpooled, new_redis_pool, new_redis_pool_clustered},
15+
redis::{new_redis_clustered_unpooled, new_redis_pool},
1616
};
1717

1818
use crate::utils::{
@@ -69,10 +69,6 @@ async fn test_app_deletion() {
6969
let mgr = new_redis_pool(dsn, &cfg).await;
7070
cache::redis::new(mgr)
7171
}
72-
CacheBackend::RedisCluster(dsn) => {
73-
let mgr = new_redis_pool_clustered(dsn, &cfg).await;
74-
cache::redis::new(mgr)
75-
}
7672
CacheBackend::RedisClusterUnpooled(dsn) => {
7773
let mgr = new_redis_clustered_unpooled(dsn).await;
7874
cache::redis::new(mgr)
@@ -157,10 +153,6 @@ async fn test_endp_deletion() {
157153
let mgr = new_redis_pool(dsn, &cfg).await;
158154
cache::redis::new(mgr)
159155
}
160-
CacheBackend::RedisCluster(dsn) => {
161-
let mgr = new_redis_pool_clustered(dsn, &cfg).await;
162-
cache::redis::new(mgr)
163-
}
164156
CacheBackend::RedisClusterUnpooled(dsn) => {
165157
let mgr = new_redis_clustered_unpooled(dsn).await;
166158
cache::redis::new(mgr)

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,24 @@ use std::{str::FromStr, time::Duration};
88

99
use redis::AsyncCommands as _;
1010
use svix_server::{
11-
cfg::{CacheType, Configuration},
11+
cfg::{Configuration, QueueType},
1212
core::types::{ApplicationId, EndpointId, MessageAttemptTriggerType, MessageId},
1313
queue::{
1414
new_pair, MessageTask, QueueTask, TaskQueueConsumer, TaskQueueDelivery, TaskQueueProducer,
1515
},
16-
redis::{new_redis_clustered_unpooled, new_redis_pool, new_redis_pool_clustered, RedisPool},
16+
redis::{new_redis_pool, new_redis_pool_clustered, RedisPool},
1717
};
1818

1919
// TODO: Don't copy this from the Redis queue test directly, place the fn somewhere both can access
20-
pub async fn get_pool(cfg: Configuration) -> RedisPool {
21-
match cfg.cache_type {
22-
CacheType::RedisCluster => {
23-
new_redis_pool_clustered(cfg.redis_dsn.as_ref().unwrap().as_str(), &cfg).await
20+
async fn get_pool(cfg: &Configuration) -> RedisPool {
21+
match cfg.queue_type {
22+
QueueType::RedisCluster => {
23+
new_redis_pool_clustered(cfg.redis_dsn.as_deref().unwrap(), cfg).await
2424
}
25-
CacheType::RedisClusterUnpooled => {
26-
new_redis_clustered_unpooled(cfg.redis_dsn.as_ref().unwrap().as_str()).await
25+
QueueType::Redis => new_redis_pool(cfg.redis_dsn.as_deref().unwrap(), cfg).await,
26+
_ => {
27+
panic!("This test should only be run when redis is configured as the queue backend")
2728
}
28-
CacheType::Redis => new_redis_pool(cfg.redis_dsn.as_ref().unwrap().as_str(), &cfg).await,
29-
_ => panic!("This test should only be run when redis is configured as the cache provider"),
3029
}
3130
}
3231

@@ -44,7 +43,7 @@ async fn test_many_queue_consumers_inner(prefix: &str, delay: Option<Duration>)
4443

4544
// This test assumes an empty queue, so load Redis and delete the test key
4645
{
47-
let pool = get_pool(cfg.clone()).await;
46+
let pool = get_pool(&cfg).await;
4847
let mut conn = pool.get().await.unwrap();
4948

5049
let _: () = conn

0 commit comments

Comments
 (0)