Struct yaque::queue::SenderBuilder
source · pub struct SenderBuilder { /* private fields */ }
Expand description
A builder for the sender side of the queue. Use this if you want to have fine-grained control over the configuration of the queue. Most defaults should be ok of most applications.
Implementations§
source§impl SenderBuilder
impl SenderBuilder
sourcepub fn new() -> SenderBuilder
pub fn new() -> SenderBuilder
Creates a new sender builder. Finish build it by invoking SenderBuilder::open
.
sourcepub fn segment_size(self, size: u64) -> SenderBuilder
pub fn segment_size(self, size: u64) -> SenderBuilder
The segment size in bytes that will trigger a new segment to be created. Segments an be bigger than this to accommodate the last element, but nothing beyond that (each segment must store at least one element).
Default value: 4 * 1024 * 1024
, or 4MB.
Panics
This function panics if size
is zero.
sourcepub fn max_queue_size(self, size: Option<u64>) -> SenderBuilder
pub fn max_queue_size(self, size: Option<u64>) -> SenderBuilder
The queue size that will block the sender from creating a new segment (until the receiver
catches up, deleting old segments). The queue can get bigger than that, but only to
accommodate the last segment (the queue must have at least one segment). Set this to None
to create an unbounded queue.
This value will be ignored if the queue has only one segment, since the queue would
deadlock otherwise. It is recommended that you set max_queue_size >> segment_size
.
Default value: None
Panics
This function panics if size
is zero.
sourcepub fn open<P: AsRef<Path>>(self, base: P) -> Result<Sender>
pub fn open<P: AsRef<Path>>(self, base: P) -> Result<Sender>
Opens a queue on a folder indicated by the base
path for sending. The
folder will be created if it does not already exist.
Errors
This function will return an IO error if the queue is already in use for sending, which is indicated by a lock file. Also, any other IO error encountered while opening will be sent.