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

Merge from redis-rs and fixes for rust 1.80.0 #2029

Merged
merged 2 commits into from
Jul 29, 2024
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
1 change: 1 addition & 0 deletions glide-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ nanoid = "0.4.0"

[features]
socket-layer = ["directories", "integer-encoding", "num_cpus", "protobuf", "tokio-util"]
standalone_heartbeat = []
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the Idea of this feature?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a standalone feature to run heartbeats on the connections which we decided not to enable yet, this is why it's behind a feature flag.


[dev-dependencies]
rsevents = "0.3.1"
Expand Down
8 changes: 4 additions & 4 deletions glide-core/src/client/standalone_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::reconnecting_connection::ReconnectingConnection;
use super::{ConnectionRequest, NodeAddress, TlsMode};
use crate::retry_strategies::RetryStrategy;
use futures::{future, stream, StreamExt};
#[cfg(standalone_heartbeat)]
#[cfg(feature = "standalone_heartbeat")]
use logger_core::log_debug;
use logger_core::log_warn;
use rand::Rng;
Expand All @@ -15,7 +15,7 @@ use redis::{PushInfo, RedisError, RedisResult, Value};
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
use tokio::sync::mpsc;
#[cfg(standalone_heartbeat)]
#[cfg(feature = "standalone_heartbeat")]
use tokio::task;

#[derive(Debug)]
Expand Down Expand Up @@ -185,7 +185,7 @@ impl StandaloneClient {
}
let read_from = get_read_from(connection_request.read_from);

#[cfg(standalone_heartbeat)]
#[cfg(feature = "standalone_heartbeat")]
for node in nodes.iter() {
Self::start_heartbeat(node.clone());
}
Expand Down Expand Up @@ -363,7 +363,7 @@ impl StandaloneClient {
}
}

#[cfg(standalone_heartbeat)]
#[cfg(feature = "standalone_heartbeat")]
fn start_heartbeat(reconnecting_connection: ReconnectingConnection) {
task::spawn(async move {
loop {
Expand Down
9 changes: 4 additions & 5 deletions glide-core/tests/test_standalone_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ mod utilities;

#[cfg(test)]
mod standalone_client_tests {
use std::collections::HashMap;

use crate::utilities::mocks::{Mock, ServerMock};
use std::collections::HashMap;

use super::*;
use glide_core::{
Expand Down Expand Up @@ -59,12 +58,12 @@ mod standalone_client_tests {
#[rstest]
#[serial_test::serial]
#[timeout(LONG_STANDALONE_TEST_TIMEOUT)]
#[cfg(standalone_heartbeat)]
#[cfg(feature = "standalone_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 {
let mut test_basics = setup_test_basics(use_tls).await;
let server = test_basics.server;
let server = test_basics.server.expect("Server shouldn't be None");
let address = server.get_client_addr();
drop(server);

Expand All @@ -79,7 +78,7 @@ mod standalone_client_tests {

let _new_server = receiver.await;
tokio::time::sleep(
glide_core::client::HEARTBEAT_SLEEP_DURATION + Duration::from_secs(1),
glide_core::client::HEARTBEAT_SLEEP_DURATION + std::time::Duration::from_secs(1),
)
.await;

Expand Down
2 changes: 1 addition & 1 deletion logger_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test-env-helpers = "0.2.2"

[dependencies]
tracing = "0.1"
tracing-appender = "0.2.2"
tracing-appender = { version = "0.2.3", default-features = false }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check if it has any implication to the behavior, does the features connected to our usage in some way?
Generally for faster builds we should disable default feature everywhere.
We'll not go all over the packages now (for redis-rs ill do it at some point) but let's try to make sure we do that when adding new packages.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

once_cell = "1.16.0"
file-rotate = "0.7.1"
tracing-subscriber = "0.3.17"
Loading