Skip to content

Commit

Permalink
editoast: remove valkey cluster client
Browse files Browse the repository at this point in the history
Signed-off-by: Florian Amsallem <[email protected]>
  • Loading branch information
flomonster committed Feb 4, 2025
1 parent 5db8398 commit 8c9879f
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 24 deletions.
5 changes: 0 additions & 5 deletions editoast/src/client/valkey_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ pub struct ValkeyConfig {
#[derivative(Default(value = "false"))]
#[clap(long, env, default_value_t = false)]
pub no_cache: bool,
#[derivative(Default(value = "false"))]
#[clap(long, env, default_value_t = false)]
pub is_cluster_client: bool,
#[derivative(Default(value = r#"Url::parse("redis://localhost:6379").unwrap()"#))]
#[arg(long, env, default_value_t = Url::parse("redis://localhost:6379").unwrap())]
/// Valkey url like `redis://[:PASSWORD@]HOST[:PORT][/DATABASE]`
Expand All @@ -24,13 +21,11 @@ impl From<ValkeyConfig> for valkey_utils::ValkeyConfig {
fn from(
ValkeyConfig {
no_cache,
is_cluster_client,
valkey_url,
}: ValkeyConfig,
) -> Self {
valkey_utils::ValkeyConfig {
no_cache,
is_cluster_client,
valkey_url,
}
}
Expand Down
18 changes: 0 additions & 18 deletions editoast/src/valkey_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ use futures::future;
use futures::FutureExt;
use redis::aio::ConnectionLike;
use redis::aio::ConnectionManager;
use redis::cluster::ClusterClient;
use redis::cluster_async::ClusterConnection;
use redis::cmd;
use redis::AsyncCommands;
use redis::Client;
Expand All @@ -22,7 +20,6 @@ use url::Url;
use crate::error::Result;

pub enum ValkeyConnection {
Cluster(ClusterConnection),
Tokio(ConnectionManager),
NoCache,
}
Expand Down Expand Up @@ -59,7 +56,6 @@ fn no_cache_cmd_handler(cmd: &redis::Cmd) -> std::result::Result<redis::Value, R
impl ConnectionLike for ValkeyConnection {
fn req_packed_command<'a>(&'a mut self, cmd: &'a redis::Cmd) -> RedisFuture<'a, redis::Value> {
match self {
ValkeyConnection::Cluster(connection) => connection.req_packed_command(cmd),
ValkeyConnection::Tokio(connection) => connection.req_packed_command(cmd),
ValkeyConnection::NoCache => future::ready(no_cache_cmd_handler(cmd)).boxed(),
}
Expand All @@ -72,9 +68,6 @@ impl ConnectionLike for ValkeyConnection {
count: usize,
) -> RedisFuture<'a, Vec<redis::Value>> {
match self {
ValkeyConnection::Cluster(connection) => {
connection.req_packed_commands(cmd, offset, count)
}
ValkeyConnection::Tokio(connection) => {
connection.req_packed_commands(cmd, offset, count)
}
Expand All @@ -92,7 +85,6 @@ impl ConnectionLike for ValkeyConnection {

fn get_db(&self) -> i64 {
match self {
ValkeyConnection::Cluster(connection) => connection.get_db(),
ValkeyConnection::Tokio(connection) => connection.get_db(),
ValkeyConnection::NoCache => 0,
}
Expand Down Expand Up @@ -267,7 +259,6 @@ impl ValkeyConnection {

#[derive(Clone)]
pub enum ValkeyClient {
Cluster(ClusterClient),
Tokio(Client),
/// This doesn't cache anything. It has no backend.
NoCache,
Expand All @@ -277,7 +268,6 @@ pub enum ValkeyClient {
pub struct ValkeyConfig {
/// Disables caching. This should not be used in production.
pub no_cache: bool,
pub is_cluster_client: bool,
pub valkey_url: Url,
}

Expand All @@ -286,21 +276,13 @@ impl ValkeyClient {
if valkey_config.no_cache {
return Ok(ValkeyClient::NoCache);
}
if valkey_config.is_cluster_client {
return Ok(ValkeyClient::Cluster(
redis::cluster::ClusterClient::new(vec![valkey_config.valkey_url]).unwrap(),
));
}
Ok(ValkeyClient::Tokio(
redis::Client::open(valkey_config.valkey_url).unwrap(),
))
}

pub async fn get_connection(&self) -> RedisResult<ValkeyConnection> {
match self {
ValkeyClient::Cluster(client) => Ok(ValkeyConnection::Cluster(
client.get_async_connection().await?,
)),
ValkeyClient::Tokio(client) => Ok(ValkeyConnection::Tokio(
client.get_connection_manager().await?,
)),
Expand Down
1 change: 0 additions & 1 deletion editoast/src/views/test_app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ impl TestAppBuilder {
},
valkey_config: ValkeyConfig {
no_cache: false,
is_cluster_client: false,
valkey_url: Url::parse("redis://localhost:6379").unwrap(),
},
};
Expand Down

0 comments on commit 8c9879f

Please sign in to comment.