pub struct FetcherService<S> { /* private fields */ }Expand description
Service layer that wraps FetcherState and manages subscriber coalescing.
When multiple callers request the same fetch, their subscribers are collected and all notified when the fetch completes.
§Type Parameter
S: The subscriber type (e.g.,chan::Sender<FetchResult>).
Implementations§
Source§impl<S> FetcherService<S>
impl<S> FetcherService<S>
Sourcepub fn new(config: Config) -> Self
pub fn new(config: Config) -> Self
Initialize the FetcherService with the give Config.
Sourcepub fn state(&self) -> &FetcherState
pub fn state(&self) -> &FetcherState
Provide a reference handle to the FetcherState.
Source§impl<S> FetcherService<S>
impl<S> FetcherService<S>
Sourcepub fn fetch(&mut self, cmd: Fetch, subscriber: Option<S>) -> FetchInitiated<S>
pub fn fetch(&mut self, cmd: Fetch, subscriber: Option<S>) -> FetchInitiated<S>
Initiate a fetch, optionally registering a subscriber.
Subscribers are coalesced: if the same (rid, node) is already being
fetched or queued, the subscriber joins the existing waiters.
If the fetch could not be initiated, and also could not be queued, then subscriber is returned to notify of the rejection.
See FetcherState::fetch.
Sourcepub fn fetched(&mut self, cmd: Fetched) -> FetchCompleted<S>
pub fn fetched(&mut self, cmd: Fetched) -> FetchCompleted<S>
Mark a fetch as completed and retrieve waiting subscribers.
Sourcepub fn cancel(&mut self, cmd: Cancel) -> FetchesCancelled<S>
pub fn cancel(&mut self, cmd: Cancel) -> FetchesCancelled<S>
Cancel all fetches for a disconnected peer, returning any orphaned subscribers.
See FetcherState::cancel.
Sourcepub fn dequeue(&mut self, from: &NodeId) -> Option<QueuedFetch>
pub fn dequeue(&mut self, from: &NodeId) -> Option<QueuedFetch>
Dequeue the next fetch for a node.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for FetcherService<S>
impl<S> RefUnwindSafe for FetcherService<S>where
S: RefUnwindSafe,
impl<S> Send for FetcherService<S>where
S: Send,
impl<S> Sync for FetcherService<S>where
S: Sync,
impl<S> Unpin for FetcherService<S>where
S: Unpin,
impl<S> UnsafeUnpin for FetcherService<S>
impl<S> UnwindSafe for FetcherService<S>where
S: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more