Struct spoolq::Queue [] [src]

pub struct Queue<T> { /* fields omitted */ }

A durable queue backed by the filesystem.

This queue stores items of type T as files in a spool directory. Files are serialized with serde_json so T must derive serde's Serialize and Deserialize traits.

The queue's directory should only contain items of the same type. Any files in the spool that fail to deserialize will be discarded.

Methods

impl<T: Serialize + Deserialize> Queue<T>
[src]

Create a new Queue<T> using the given directory path for storage.

Push an item into the Queue.

Pop an item off the queue.

This method returns the first matching directory entry. Queue ordering cannot be guaranteed to be consistent across all operating systems and filesystems, as the serialized file will be chosen based on the filesystem's directory entry ordering.

Popped items are not removed from the filesystem immediately; instead, they are marked for deletion. Use flush() to cause the items to be permanently removed from the underlying filesystem.

Pop an item off the queue matching the filter function.

This method works the same as pop(), except the item must match the given function or it is not popped off the queue.

Flush removes all pending item files marked for deletion.

Recover unmarks all pending item files that were previously marked for deletion.

Use recover to ensure that popped items are processed at least once, when it is uncertain whether they were processed due to a crash.

This method is only recommended if items are being processed idempotently.

Trait Implementations

impl<T: Clone> Clone for Queue<T>
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<T: Debug> Debug for Queue<T>
[src]

Formats the value using the given formatter.