Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put CMD heartbeat behind a feature flag. #335

Merged
merged 1 commit into from
Aug 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading