pub struct MemoryFeed { /* private fields */ }Expand description
A Feed held in this process, for a single instance.
Clones share one feed, so a lister and a reader can each hold one. Units are delivered in the order they were published, and a failed unit goes to the back of the queue.
Implementations§
Source§impl MemoryFeed
impl MemoryFeed
Sourcepub fn new() -> MemoryFeed
pub fn new() -> MemoryFeed
An empty feed that dead-letters a unit failed on its tenth delivery.
Sourcepub fn with_attempt_cap(cap: NonZeroU32) -> MemoryFeed
pub fn with_attempt_cap(cap: NonZeroU32) -> MemoryFeed
An empty feed that dead-letters a unit failed on delivery cap.
Sourcepub fn from_section(section: &FeedSection) -> Result<MemoryFeed, ConfigError>
pub fn from_section(section: &FeedSection) -> Result<MemoryFeed, ConfigError>
An empty feed built from a feed: { memory: {} } section, with the
section’s attempt_cap, else 10.
§Errors
ConfigError::Component when the section names another backend,
when the memory body holds a key, or when the section sets
location or settling_window.
§Examples
use spate_core::config::{ComponentConfig, FeedSection, YamlValue};
use spate_core::feed::memory::MemoryFeed;
use std::num::NonZeroU32;
let body = YamlValue::Mapping(Default::default());
let mut section = FeedSection::new(ComponentConfig::new("memory", body));
section.attempt_cap = NonZeroU32::new(3);
let feed = MemoryFeed::from_section(§ion).unwrap();
assert_eq!(feed.counts().visible, 0);Sourcepub fn counts(&self) -> FeedCounts
pub fn counts(&self) -> FeedCounts
The units this feed holds, by state.
Sourcepub fn dead_letters(&self) -> Vec<Unit>
pub fn dead_letters(&self) -> Vec<Unit>
The units moved to the dead-letter list, in the order they moved.
Trait Implementations§
Source§impl Clone for MemoryFeed
impl Clone for MemoryFeed
Source§impl Debug for MemoryFeed
impl Debug for MemoryFeed
Source§impl Default for MemoryFeed
impl Default for MemoryFeed
Source§fn default() -> MemoryFeed
fn default() -> MemoryFeed
Returns the “default value” for a type. Read more
Source§impl Feed for MemoryFeed
impl Feed for MemoryFeed
Source§fn backend(&self) -> &str
fn backend(&self) -> &str
The key that names this backend in a
feed: section, such as
"memory". The runtime refuses a feed whose key differs from the
one the pipeline’s FeedSection names.Source§fn set_waker(&self, waker: FeedWaker)
fn set_waker(&self, waker: FeedWaker)
Hand the backend the waker it signals when a unit becomes ready to
receive, including one that arrived before this call, and after a
receive that takes some units and leaves others. A
receive that takes nothing sends no signal. Called before the first
receive; a later call replaces the waker.Source§fn receive(&self, max: usize) -> Result<Vec<Delivery>, FeedError>
fn receive(&self, max: usize) -> Result<Vec<Delivery>, FeedError>
Up to
max deliveries the backend has buffered, oldest first. Never
waits; returns an empty list when nothing is ready. Read moreSource§fn renew(&self, receipt: Receipt) -> Result<(), FeedError>
fn renew(&self, receipt: Receipt) -> Result<(), FeedError>
Mark a held unit as still in work. Read more
Source§fn acknowledge(&self, receipt: Receipt) -> Result<(), FeedError>
fn acknowledge(&self, receipt: Receipt) -> Result<(), FeedError>
Remove a unit from the feed as done. Only the ack rule decides when a
caller may send it. Read more
Source§fn fail(&self, receipt: Receipt, reason: &str) -> Result<(), FeedError>
fn fail(&self, receipt: Receipt, reason: &str) -> Result<(), FeedError>
Return a held unit that this reader could not process, so the feed
delivers it again. At the feed’s delivery cap the unit moves to its
dead-letter destination instead.
reason is for the feed’s logs. Read moreSource§fn publish(&self, unit: Unit) -> Confirmation ⓘ
fn publish(&self, unit: Unit) -> Confirmation ⓘ
Add a unit to the feed. The returned
Confirmation resolves once
the feed has stored the unit or refused it. A unit published twice is
delivered twice.Source§fn read_depth(&self, of: DepthOf) -> Option<DepthReading>
fn read_depth(&self, of: DepthOf) -> Option<DepthReading>
Count what the feed, or its dead-letter destination, holds. The
returned
DepthReading settles once the backend has read the
counts. Never waits. Read moreSource§fn attach_metrics(&self, _cx: FeedMetricsCtx)
fn attach_metrics(&self, _cx: FeedMetricsCtx)
Receive the
Meter and per-partition setting for the backend’s own
metric families. Called before the source is handed the feed, once for
each pipeline that runs it, with that pipeline’s labels and that
pipeline’s metrics.per_partition_detail. Resolve handles here and keep
them, which &self leaves to interior mutability. Read moreSource§fn hands_back(&self) -> bool
fn hands_back(&self) -> bool
Whether a stopping worker reads this feed’s units to the
STOP_RESERVE and hands back the rest, as the module docs’
“Stopping” order describes. Startup refuses a drain timeout no longer
than the reserve on a feed that answers true. The default returns
false.Source§fn stop_receiving(&self)
fn stop_receiving(&self)
Receive nothing more: the worker is stopping. Units already buffered
are the backend’s to give back. The default does nothing.
Source§fn hand_back(&self, _receipt: Receipt) -> Result<(), FeedError>
fn hand_back(&self, _receipt: Receipt) -> Result<(), FeedError>
Return a held unit for another reader to take at once. The
delivery does not count as a failure; a backend that counts
deliveries toward a dead-letter limit counts this one as it counts
any delivery. Read more
Source§fn close(&self, _within: Duration) -> Option<Confirmation>
fn close(&self, _within: Duration) -> Option<Confirmation>
Send what the backend still has queued and give up every unit still
held, within
within. Called once, after the pipeline’s final
commit. Never waits: the returned Confirmation settles when the
backend is done, and a caller stops waiting for it after within. Read moreAuto Trait Implementations§
impl Freeze for MemoryFeed
impl RefUnwindSafe for MemoryFeed
impl Send for MemoryFeed
impl Sync for MemoryFeed
impl Unpin for MemoryFeed
impl UnsafeUnpin for MemoryFeed
impl UnwindSafe for MemoryFeed
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more