RelocatableQueueEdge

Struct RelocatableQueueEdge 

Source
pub struct RelocatableQueueEdge<T> { /* private fields */ }
Expand description

A queue edge that can relocate to a new backing queue on failure.

Wraps a FabricQueue with a HandoffReader so that when the current queue becomes unavailable (lease expired, disconnected), the edge can poll for a new QueueLocator published by the producer and rebind transparently.

§Relocation protocol

When push or pop fails with a recoverable error:

  1. The producer allocates a new queue (via MemBuilder), publishes the new QueueLocator through a HandoffWriter, and resumes pushing.
  2. The consumer calls relocate, which polls the HandoffReader for a new locator. If the generation has bumped, it creates a new FabricQueue from the new locator and resumes.

Implementations§

Source§

impl<T: Serialize + DeserializeOwned> RelocatableQueueEdge<T>

Source

pub fn new( queue: FabricQueue<T>, locator: QueueLocator, handoff_reader: HandoffReader<QueueLocator>, ) -> Self

Create a new relocatable edge.

  • queue: the initial FabricQueue to use.
  • locator: the QueueLocator describing the queue’s location.
  • handoff_reader: a reader for detecting when the producer has relocated the queue to a new lease.
Source

pub fn push(&mut self, item: &T) -> Result<(), EdgeError>

Push an item onto the queue.

Returns Ok(()) on success. If the queue is full, returns EdgeError::QueueFull. On lease expiry or disconnection, attempts relocation before returning the error.

Source

pub fn pop(&mut self) -> Result<Option<T>, EdgeError>

Pop an item from the queue.

Returns Ok(Some(item)) if an item was available, Ok(None) if the queue is empty. On lease expiry or disconnection, attempts relocation before returning the error.

Source

pub fn relocate(&mut self) -> Result<(), EdgeError>

Poll the handoff reader for a new queue locator.

If a new generation is found, creates a new FabricQueue from the published locator and switches to it. Returns Ok(()) if relocation succeeded or no relocation was needed.

Source

pub fn generation(&self) -> FenceEpoch

The current edge generation (epoch).

Source

pub fn locator(&self) -> &QueueLocator

The current queue locator.

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.