pub struct PriorityFanout { /* private fields */ }Implementations§
Source§impl PriorityFanout
impl PriorityFanout
pub const PAYLOAD_BYTES: usize = PAYLOAD_BYTES
Sourcepub fn create(
base_path: impl AsRef<Path>,
n_priorities: usize,
ring_capacity: usize,
) -> Result<Self, FanoutError>
pub fn create( base_path: impl AsRef<Path>, n_priorities: usize, ring_capacity: usize, ) -> Result<Self, FanoutError>
Create a fanout with n_priorities levels (0..n; 0 = lowest,
n-1 = highest), each ring sized to ring_capacity slots. All
rings have the same capacity; configure based on the expected
burst per priority.
Sourcepub fn open(
base_path: impl AsRef<Path>,
n_priorities: usize,
ring_capacity: usize,
) -> Result<Self, FanoutError>
pub fn open( base_path: impl AsRef<Path>, n_priorities: usize, ring_capacity: usize, ) -> Result<Self, FanoutError>
Open an existing fanout. Pass the SAME n_priorities and
ring_capacity the creator used.
pub fn n_priorities(&self) -> usize
Sourcepub fn submit(&self, priority: usize, payload: &[u8]) -> Result<(), FanoutError>
pub fn submit(&self, priority: usize, payload: &[u8]) -> Result<(), FanoutError>
Submit a payload at the given priority level. priority must
be in 0..n_priorities. Returns Err(Ring(Full)) when that
priority’s ring is full.
Sourcepub fn try_drain_highest(&self, out: &mut [u8]) -> Result<usize, FanoutError>
pub fn try_drain_highest(&self, out: &mut [u8]) -> Result<usize, FanoutError>
Drain ONE item from the highest non-empty priority. Returns
the priority of the item that was drained. Returns
Err(Empty) only when ALL rings are empty.
Sourcepub fn try_drain_priority(
&self,
priority: usize,
out: &mut [u8],
) -> Result<(), FanoutError>
pub fn try_drain_priority( &self, priority: usize, out: &mut [u8], ) -> Result<(), FanoutError>
Drain ONE item from a specific priority. Returns
Err(Ring(Empty)) when that ring is empty. Useful for
dedicated workers that only handle a specific class.
Sourcepub fn active_priorities(&self) -> u64
pub fn active_priorities(&self) -> u64
Snapshot the current active-priority bitmap.
Sourcepub fn highest_active_priority(&self) -> Option<usize>
pub fn highest_active_priority(&self) -> Option<usize>
Highest currently-active priority (None when all empty).
Sourcepub fn approx_pending(&self, priority: usize) -> Option<usize>
pub fn approx_pending(&self, priority: usize) -> Option<usize>
Approximate pending count for a specific priority (each ring’s own approx_len).
Sourcepub fn approx_total_pending(&self) -> usize
pub fn approx_total_pending(&self) -> usize
Approximate total pending across all priorities.
Sourcepub fn flush(&self) -> Result<(), FanoutError>
pub fn flush(&self) -> Result<(), FanoutError>
Sync the bitmap and all rings to disk.
Sourcepub fn flush_async(&self) -> Result<(), FanoutError>
pub fn flush_async(&self) -> Result<(), FanoutError>
Non-blocking flush of the bitmap and all rings. Delegates to each inner primitive’s flush_async. Note: Windows is only partially async (sync to page cache, not to disk).