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:
- The producer allocates a new queue (via
MemBuilder), publishes the newQueueLocatorthrough aHandoffWriter, and resumes pushing. - The consumer calls
relocate, which polls theHandoffReaderfor a new locator. If the generation has bumped, it creates a newFabricQueuefrom the new locator and resumes.
Implementations§
Source§impl<T: Serialize + DeserializeOwned> RelocatableQueueEdge<T>
impl<T: Serialize + DeserializeOwned> RelocatableQueueEdge<T>
Sourcepub fn new(
queue: FabricQueue<T>,
locator: QueueLocator,
handoff_reader: HandoffReader<QueueLocator>,
) -> Self
pub fn new( queue: FabricQueue<T>, locator: QueueLocator, handoff_reader: HandoffReader<QueueLocator>, ) -> Self
Create a new relocatable edge.
queue: the initialFabricQueueto use.locator: theQueueLocatordescribing the queue’s location.handoff_reader: a reader for detecting when the producer has relocated the queue to a new lease.
Sourcepub fn push(&mut self, item: &T) -> Result<(), EdgeError>
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.
Sourcepub fn pop(&mut self) -> Result<Option<T>, EdgeError>
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.
Sourcepub fn relocate(&mut self) -> Result<(), EdgeError>
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.
Sourcepub fn generation(&self) -> FenceEpoch
pub fn generation(&self) -> FenceEpoch
The current edge generation (epoch).
Sourcepub fn locator(&self) -> &QueueLocator
pub fn locator(&self) -> &QueueLocator
The current queue locator.