Skip to content

Add Client Workaround With a Load Balancer #220

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

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

JiaYingZhang
Copy link
Contributor

This PR add client workaound with a load balancer.

Client Workaround With a Load Balancer

The implementation method references Python rstream client.

  • Add a new load_balancer_mode option to ClientOptions, defaulting to false.
  • Implemented the requirement for the producer to connect to the leader node.
  • Added usage instructions to Readme.md.

@Gsantomaggio
Copy link
Member

@JiaYingZhang Thank you.

  • It seems there is a format problem.
  • is there a way to create tests to cover the code?

@wolf4ood @DanielePalaia do you have a chance to check the PR?

@JiaYingZhang
Copy link
Contributor Author

JiaYingZhang commented Jul 29, 2024 via email

src/consumer.rs Outdated
loop {
let temp_client = Client::connect(options.clone()).await?;
let mapping = temp_client.connection_properties().await;
let advertised_host = mapping.get("advertised_host").unwrap();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please remove the unwrap, if the property advertised_host is not found return an error.
Same for the producer

@JiaYingZhang
Copy link
Contributor Author

JiaYingZhang commented Jul 30, 2024 via email

@wolf4ood
Copy link
Collaborator

@JiaYingZhang

i guess it's fine to skip the current tmp_client one if there is no advertised_host property

@JiaYingZhang
Copy link
Contributor Author

@Gsantomaggio @wolf4ood
Is anything I need to do?

@Gsantomaggio
Copy link
Member

@JiaYingZhang thanks a lot.
There is an error on the CI:

    Checking rabbitmq-stream-client v0.4.2 (/home/runner/work/rabbitmq-stream-rust-client/rabbitmq-stream-rust-client)
error: this bound is already specified as the supertrait of `MetricsCollector`
   --> src/environment.rs:124:44
    |
124 |         collector: impl MetricsCollector + Send + Sync + 'static,
    |                                            ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#implied_bounds_in_impls
    = note: `-D clippy::implied-bounds-in-impls` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::implied_bounds_in_impls)]`
help: try removing this bound
    |
124 -         collector: impl MetricsCollector + Send + Sync + 'static,
124 +         collector: impl MetricsCollector + Sync + 'static,
    |

error: this bound is already specified as the supertrait of `MetricsCollector`
   --> src/environment.rs:124:51
    |
124 |         collector: impl MetricsCollector + Send + Sync + 'static,
    |                                                   ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#implied_bounds_in_impls
help: try removing this bound
    |
124 -         collector: impl MetricsCollector + Send + Sync + 'static,
124 +         collector: impl MetricsCollector + Send + 'static,
    |

error: could not compile `rabbitmq-stream-client` (lib) due to 2 previous errors
make: *** [Makefile:8: clippy] Error 101
Error

Not sure it is from this PR. @wolf4ood ?

@wolf4ood
Copy link
Collaborator

Seems a new clippy rule, @JiaYingZhang I think you can simply run
cargo clippy --fix --lib -p rabbitmq-stream-client and it should fix it

@JiaYingZhang
Copy link
Contributor Author

@wolf4ood
It does't work,nothing changes.
Is this related to the version of Cargo?
My cargo version:

cargo 1.77.1 (e52e36006 2024-03-26)

@wolf4ood
Copy link
Collaborator

@JiaYingZhang you might need to update the toolchain for automatically applying the fix,

otherwise you can do it manually by just removing Send + Sync there

@JiaYingZhang
Copy link
Contributor Author

@wolf4ood
Yes, you're right. Because this isn't my code, I'm being cautious : )
i will fix it up right now. Thank you for your guidance.

@Gsantomaggio
Copy link
Member

Tests are green. There is a problem with Codecov ( I will maybe remove it or consider it optional).
Can we merge @DanielePalaia @wolf4ood ?
Thank you all

@Gsantomaggio Gsantomaggio merged commit 3aa3c8a into rabbitmq:main Jul 30, 2024
1 check failed
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