tokahuke / yaque

Yaque is yet another disk-backed persistent queue for Rust.
Other
81 stars 11 forks source link

Create a `Peeker<T>` to allow iterating through a queue without consuming the items. #5

Closed tokahuke closed 3 years ago

tokahuke commented 4 years ago

The Receiver<T> consumes the items from the queue (like .into_iter()). It Would Be Nice© to have an equivalent to .iter().

vedantroy commented 3 years ago

Hate to be this guy, but is there any update on this?

~Another useful alternative would be allowing submission of batches of items, but consuming reads only read 1 item at a time (this would only be possible if yaque supports serializing a vec of items, instead of just bytes -- I haven't looked into yaque's API long enough to determine whether this is the case).~ Looks like Yaque supports this.

Update: Never-mind. It looks like the commit operation is basically a form of peeking?

tokahuke commented 3 years ago

Yes! I have opened this issue a long time ago because I have thought this feature was useful. It looks like it is not. Maybe I will close this issue as irrelevant.

tokahuke commented 3 years ago

... except that recv_batch and friends materialize the peeked result. This may be undesirable in some cases (imagine you want only to count the number of elements in the queue!!).

I think we will need a special API for this, but it can be integrated n the Receiver itself, but I will leave it for a future release (in the "short term"). there is too much already going on in 0.6.0...

tokahuke commented 3 years ago

Implemented as QueueIter in PR #12 .