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

connect_and_check: Allow choosing which connections to refresh. #112

Merged
merged 1 commit into from
Feb 5, 2024

Conversation

nihohit
Copy link

@nihohit nihohit commented Jan 29, 2024

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.

@nihohit nihohit force-pushed the connect-and-check branch 2 times, most recently from 7968500 to 486af81 Compare January 29, 2024 15:24
addr,
params.clone(),
None,
RefreshConnectionType::OnlyUserConnection,
Copy link

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?

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;
Copy link

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,
Copy link

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?

Choose a reason for hiding this comment

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

yup

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>),
Copy link

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.
Copy link

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>(
Copy link

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>(
Copy link

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"),
Copy link

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);
Copy link

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);
Copy link

Choose a reason for hiding this comment

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

same

@shachlanAmazon
Copy link

@barshaul round

Copy link

@barshaul barshaul left a 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 👌

@shachlanAmazon shachlanAmazon merged commit dc77881 into amazon-contributing:main Feb 5, 2024
10 checks passed
@nihohit nihohit deleted the connect-and-check branch February 5, 2024 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants