-
Notifications
You must be signed in to change notification settings - Fork 102
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
AsyncClient::get_stream() support unbounded channel #191
AsyncClient::get_stream() support unbounded channel #191
Conversation
Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
A few people have asked about this kind of thing since the original sync consumer. I'll merge this with the next point release, but may reconsider the API... having a special integer value for "no limit" seems like such a C thing to do :-) Maybe an But also, we should be consistent with |
…usize> Signed-off-by: fbrouille <fbrouille@users.noreply.github.com>
IMO |
Yeah, nice. Thanks for updating it. Maybe I'll rename the parameter But I think I will take it a step further and make it into an
which would convert to Thanks for the PR. |
To be clear... The PR, as submitted, broke the build of the examples:
but changing it to an
Plus it's nicer to be able to call the function for a bounded channel without needing the |
thank you for the fix |
Thanks again for the PR. I will update the synchronous channel version to do the same thing when I do the next major update, when I can make some breaking changes (v0.13) |
Sometimes, a MQTT broker provides a lot of topics with a retain message for each of them.
Within current implementation,
AsyncClient
relies on a bounded channel that may be fully filled very quickly, even if messages are consumed and processed very fast. Fully filled the bounded channel results in losing messages. Note that I tried to determinate the relevant channel buffer capacity, but this might be difficult.This PR aims to fix losing messages by using an unbounded channel if
buffer_sz
is0
. This way, the underlying channel will grow up automatically to buffer all received messages.Of course, this is not the ideal solution for all use cases because of the memory footprint. I think that a MQTT broker usually does not provide so many topics with retain messages. So generally setting
buffer_sz
to a positive number is the way to go.