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

Multi-client requests #394

Closed
rsalmei opened this issue Feb 16, 2023 · 2 comments
Closed

Multi-client requests #394

rsalmei opened this issue Feb 16, 2023 · 2 comments

Comments

@rsalmei
Copy link

rsalmei commented Feb 16, 2023

Hi!

Similar to #268, I also need to manage several client connections at the same time, but instead of load balancing them, I'll be calling them all with something like futures_util::join_all (on a LAN), merging their responses together with their names, and responding the call with this "enriched" answer.

So, if I had:

trait Doctor {
    async fn get_specialties() -> Vec<String>;
}

I'd need:

trait Doctors {
    async fn get_specialties() -> Vec<(String, Vec<String>)>;
}

How would I handle errors in this scenario? And timeouts, returning only the answers I could get in time?
Any tips/concerns on making this happen?
Thank you!

@tikue
Copy link
Collaborator

tikue commented Feb 4, 2024

Hi! Sorry for not responding last year. For something like this, I think the Doctors service implementation would be able to implement everything you said pretty straightforwardly: send out N requests with whatever deadline will allow the service to respond in time; iterate over the responses, filtering out any deadline-exceeded errors; and then return the result?

If you're still interested in this and struggling to implement something, feel free to share a link to your work in progress, and I'll try to take a look.

@rsalmei
Copy link
Author

rsalmei commented Feb 6, 2024

Hey, don't worry, thanks.
I'd forgotten this was still open, join_all worked nicely! I can call a single device or multiple ones on demand.
Thank you.

@rsalmei rsalmei closed this as completed Feb 6, 2024
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

No branches or pull requests

2 participants