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

Improve reconnect randomization #868

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jarema
Copy link
Member

@Jarema Jarema commented Mar 8, 2023

No description provided.

@Jarema Jarema requested a review from caspervonb March 8, 2023 14:57
@Jarema Jarema force-pushed the jarema/improve-reconnect-randomization branch from 1c65c0b to a721429 Compare March 8, 2023 16:11
Copy link
Collaborator

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

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

Some nits

@@ -99,8 +101,13 @@ impl Connector {

pub(crate) async fn try_connect(&mut self) -> Result<(ServerInfo, Connection), io::Error> {
let mut error = None;
let server_addrs = {
let mut rng = thread_rng();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is already mut, so connector could own the rng without issue.

Suggested change
let mut rng = thread_rng();
let mut rng = thread_rng();

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure.
Connector needs to be Send.

Do we prefer to just call it at try_connect or put it behind Arc?
I think the former.

async-nats/src/connector.rs Outdated Show resolved Hide resolved
@Jarema Jarema force-pushed the jarema/improve-reconnect-randomization branch from a721429 to f432fa4 Compare March 8, 2023 22:35
Copy link
Collaborator

@caspervonb caspervonb left a comment

Choose a reason for hiding this comment

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

lgtm

@caspervonb caspervonb force-pushed the jarema/improve-reconnect-randomization branch from f432fa4 to bcf5ca6 Compare March 14, 2023 07:43
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.

2 participants