Skip to main content

PriorityFanout

Struct PriorityFanout 

Source
pub struct PriorityFanout { /* private fields */ }

Implementations§

Source§

impl PriorityFanout

Source

pub const PAYLOAD_BYTES: usize = PAYLOAD_BYTES

Source

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.

Source

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.

Source

pub fn n_priorities(&self) -> usize

Source

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.

Source

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.

Source

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.

Source

pub fn active_priorities(&self) -> u64

Snapshot the current active-priority bitmap.

Source

pub fn highest_active_priority(&self) -> Option<usize>

Highest currently-active priority (None when all empty).

Source

pub fn approx_pending(&self, priority: usize) -> Option<usize>

Approximate pending count for a specific priority (each ring’s own approx_len).

Source

pub fn approx_total_pending(&self) -> usize

Approximate total pending across all priorities.

Source

pub fn flush(&self) -> Result<(), FanoutError>

Sync the bitmap and all rings to disk.

Source

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).

Trait Implementations§

Source§

impl AdaptiveInstance for PriorityFanout

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.