Open tekjar opened 6 years ago
I have a suggestion how to fix the "auto acks" problem. I suggest to extent the enum Notification:: Publish(Publish) with information needed for confirming a received message. => enum Notification:: Publish(Publish,AckInfo) and not, as now, confirming incoming message immediately. After the Notification:: Publish(Publish,AckInfo) was processed in the user code, Rust calls drop() method for the AckInfo struct. Within this method should the acknowledgement be sent to the Brocker. For this AckInfo must implement the Dorp Traid. This is only the rough approach to solve this problem. I'm too new in rust to fix the problem myself.
@stanmueller Sounds reasonable to me. This AckInfo
would contain a oneshot::Sender
.
Another thing that comes to my mind is a ordinary Stream
instead of the crossbeam channel - but this would be a complete different API. e.g
fn subscribe(topic, qos, consumer: impl Stream<Item = Publish, Error = io::Error>) -> Result<..>
if you're lazy you can just pass a channel tx half.
@stanmueller Yeah that sounds plausible. But I should say that disabling auto-ack isn't a priority for me now. Will come back to this after next release. But you are welcome to give it a shot now :). I would be interested in how it looks
94
Sometimes users might want to send acks after handling incoming publishes. Add compile time feature to disable auto acks and provide method to send ack