-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
@JiaYingZhang Thank you.
@wolf4ood @DanielePalaia do you have a chance to check the PR? |
yes,I’ll fix it right away
…---- Replied Message ----
| From | Gabriele ***@***.***> |
| Date | 07/29/2024 19:59 |
| To | rabbitmq/rabbitmq-stream-rust-client ***@***.***> |
| Cc | kaka ***@***.***>,
Mention ***@***.***> |
| Subject | Re: [rabbitmq/rabbitmq-stream-rust-client] Add Client Workaround With a Load Balancer (PR #220) |
@JiaYingZhang Thank you.
It seems there is a format problem.
is there a way to create tests to cover the code?
@***@***.*** do you have a chance to check the PR?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
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(); |
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 remove the unwrap
, if the property advertised_host
is not found return an error.
Same for the producer
I can't find a suitable error return in ConsumerCreateError, and I don't think it's necessary to add a new error type for this.
I will remove unwrap , if there is no advertised_host value in connection_properties, it will create the new connection and ignore the current one.
Is this approach acceptable?
| |
张嘉颖
|
|
***@***.***
|
---- Replied Message ----
| From | Enrico ***@***.***> |
| Date | 7/30/2024 15:09 |
| To | ***@***.***> |
| Cc | ***@***.***> ,
***@***.***> |
| Subject | Re: [rabbitmq/rabbitmq-stream-rust-client] Add Client Workaround With a Load Balancer (PR #220) |
@wolf4ood requested changes on this pull request.
In src/consumer.rs:
@@ -76,12 +76,26 @@ impl ConsumerBuilder {
metadata.replicas,
stream
);
- client = Client::connect(ClientOptions {
- host: replica.host.clone(),
- port: replica.port as u16,
- ..self.environment.options.client_options
- })
- .await?;
+ let load_balancer_mode = self.environment.options.client_options.load_balancer_mode;
+ if load_balancer_mode {
+ let options = self.environment.options.client_options.clone();
+ loop {
+ let temp_client = Client::connect(options.clone()).await?;
+ let mapping = temp_client.connection_properties().await;
+ let advertised_host = mapping.get("advertised_host").unwrap();
Please remove the unwrap, if the property advertised_host is not found return an error.
Same for the producer
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
i guess it's fine to skip the current |
@Gsantomaggio @wolf4ood |
@JiaYingZhang thanks a lot.
Not sure it is from this PR. @wolf4ood ? |
Seems a new clippy rule, @JiaYingZhang I think you can simply run |
@wolf4ood
|
@JiaYingZhang you might need to update the toolchain for automatically applying the fix, otherwise you can do it manually by just removing |
@wolf4ood |
Tests are green. There is a problem with Codecov ( I will maybe remove it or consider it optional). |
This PR add client workaound with a load balancer.
Client Workaround With a Load Balancer
The implementation method references Python rstream client.