-
Notifications
You must be signed in to change notification settings - Fork 16
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
connect_and_check: Allow choosing which connections to refresh. #112
connect_and_check: Allow choosing which connections to refresh. #112
Conversation
7968500
to
486af81
Compare
addr, | ||
params.clone(), | ||
None, | ||
RefreshConnectionType::OnlyUserConnection, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the DNS has changed, why are we refreshing only the user connection?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR tries to minimize changes to get_or_create_conn
, and ATM we don't use management connections.
where | ||
C: ConnectionLike + Connect + Send + Clone + 'static, | ||
C: ConnectionLike + Send + Clone + Sync + Connect + 'static, | ||
{ | ||
if let Some(node) = node { | ||
let mut conn = node.user_connection.await; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line can be moved under the dns check
Err(_) => connect_and_check(addr, params.clone(), None).await, | ||
Ok(_) => Ok(AsyncClusterNode::new( | ||
async { conn }.boxed().shared(), | ||
None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so in this PR you're not adding the management connection yet, just adding the functionality?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is large enough, as it is. I don't want to make it larger than it needs to be.
#[doc(hidden)] | ||
#[must_use] | ||
pub enum ConnectAndCheckResult<C> { | ||
Success(AsyncClusterNode<C>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a comment explaining each one, something like: Success -> All required connections succeeded, ManagementConnectionFailed => Only the management connection failed to be established, Failed => all required connections failed
}; | ||
|
||
if let Some(new_conn) = management_connection.as_mut() { | ||
// The new IP matches the existing one. Use this connection for the management connection. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment should be moved to the else in line 262
} | ||
} | ||
|
||
async fn create_management_connection<C>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function is redundant, we can add the warning into the ManagementConnectionFailed result constructor
} | ||
} | ||
|
||
async fn create_user_connection<C>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_and_setup_management_connection and create_user_connection names should be the same in all but the connection name (user/management)
) -> (AsyncClusterNode<MockConnection>, redis::RedisError) { | ||
match result { | ||
ConnectAndCheckResult::ManagementConnectionFailed { node, err } => (node, err), | ||
ConnectAndCheckResult::Success(_) => panic!("full success"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please make the panic messages more informative
.await; | ||
let (node, _) = assert_partial_result(result); | ||
assert!(node.management_connection.is_none()); | ||
assert_eq!(node.ip, None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why? seems irrelevant for this test
.await; | ||
let (node, _) = assert_partial_result(result); | ||
assert!(node.management_connection.is_none()); | ||
assert_eq!(node.ip, None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
@barshaul round |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_and_setup_management_connection -> create_management_connection (or create_user_connection -> create_and_setup_user_connection)
other than that 👌
b752e78
to
6e2739c
Compare
Issue #, if available:
Description of changes:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.