Skip to content

Commit

Permalink
Put CMD heartbeat behind a feature flag.
Browse files Browse the repository at this point in the history
We're not sure we want this for beta, since there are problems with
blocking commands.
  • Loading branch information
shachlanAmazon committed Aug 6, 2023
1 parent 49b22c1 commit 6a7bfe7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion babushka-core/src/client/client_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ use super::reconnecting_connection::ReconnectingConnection;
use crate::connection_request::{AddressInfo, ConnectionRequest, TlsMode};
use crate::retry_strategies::RetryStrategy;
use futures::{stream, StreamExt};
use logger_core::{log_debug, log_trace, log_warn};
#[cfg(cmd_heartbeat)]
use logger_core::log_debug;
use logger_core::{log_trace, log_warn};
use protobuf::EnumOrUnknown;
use redis::{RedisError, RedisResult, Value};
use std::sync::Arc;
#[cfg(cmd_heartbeat)]
use tokio::task;

enum ReadFromReplicaStrategy {
Expand Down Expand Up @@ -119,6 +122,7 @@ impl ClientCMD {
let read_from_replica_strategy =
get_read_from_replica_strategy(&connection_request.read_from_replica_strategy);

#[cfg(cmd_heartbeat)]
for node in nodes.iter() {
Self::start_heartbeat(node.clone());
}
Expand Down Expand Up @@ -207,6 +211,7 @@ impl ClientCMD {
}
}

#[cfg(cmd_heartbeat)]
fn start_heartbeat(reconnecting_connection: ReconnectingConnection) {
task::spawn(async move {
loop {
Expand Down
1 change: 1 addition & 0 deletions babushka-core/tests/test_client_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ mod client_cmd_tests {

#[rstest]
#[timeout(LONG_CMD_TEST_TIMEOUT)]
#[cfg(cmd_heartbeat)]
fn test_detect_disconnect_and_reconnect_using_heartbeat(#[values(false, true)] use_tls: bool) {
let (sender, receiver) = tokio::sync::oneshot::channel();
block_on_all(async move {
Expand Down

0 comments on commit 6a7bfe7

Please sign in to comment.