Struct holochain::prelude::kitsune_p2p::dependencies::kitsune_p2p_fetch::FetchPool
source · pub struct FetchPool { /* private fields */ }
Expand description
A FetchPool tracks a set of FetchKey
s (op hashes) to be fetched,
each of which can have multiple sources associated with it.
When adding the same key twice, the sources are merged by appending the newest
source to the front of the list of sources, and the contexts are merged by the
method defined in FetchPoolConfig
.
Each item consists of a FetchKey (Op) and one or more sources (Agent) from which to fetch it.
Items can be retrieved in batches using FetchPool::get_items_to_fetch
. Any items which
were considered while building the batch, either because they were still awaiting a response
or because they were returned in the batch, will be moved to the end of the queue. This makes
fetching items reasonably fair.
Implementations§
source§impl FetchPool
impl FetchPool
sourcepub fn new(config: Arc<dyn FetchPoolConfig>) -> FetchPool
pub fn new(config: Arc<dyn FetchPoolConfig>) -> FetchPool
Constructor
sourcepub fn new_bitwise_or() -> FetchPool
pub fn new_bitwise_or() -> FetchPool
Constructor, using only the “hardcoded” config (TODO: remove)
sourcepub fn push(&self, args: FetchPoolPush)
pub fn push(&self, args: FetchPoolPush)
Add an item to the queue. If the FetchKey does not already exist, add it to the end of the queue. If the FetchKey exists, add the new source and merge the context in, without changing the position in the queue.
sourcepub fn check_item(&self, key: &FetchKey) -> (bool, Option<FetchContext>)
pub fn check_item(&self, key: &FetchKey) -> (bool, Option<FetchContext>)
Check if an item is in the fetch pool and what its context is.
sourcepub fn remove(&self, key: &FetchKey) -> Option<FetchPoolItem>
pub fn remove(&self, key: &FetchKey) -> Option<FetchPoolItem>
When an item has been successfully fetched, we can remove it from the queue.
sourcepub fn get_items_to_fetch(
&self
) -> Vec<(FetchKey, Arc<KitsuneSpace>, FetchSource, Option<FetchContext>)>
pub fn get_items_to_fetch( &self ) -> Vec<(FetchKey, Arc<KitsuneSpace>, FetchSource, Option<FetchContext>)>
Get a list of the next items to be fetched.
sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Get the current size of the fetch pool. This is the number of outstanding items
and may be different to the size of response from get_items_to_fetch
because it
ignores retry delays.
sourcepub fn check_sources(&self)
pub fn check_sources(&self)
Check the state of all sources and remove any that have expired. See the docs on State::check_sources for details.
Trait Implementations§
source§impl From<FetchPool> for FetchPoolReader
impl From<FetchPool> for FetchPoolReader
source§fn from(original: FetchPool) -> FetchPoolReader
fn from(original: FetchPool) -> FetchPoolReader
Auto Trait Implementations§
impl !RefUnwindSafe for FetchPool
impl Send for FetchPool
impl Sync for FetchPool
impl Unpin for FetchPool
impl !UnwindSafe for FetchPool
Blanket Implementations§
source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
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<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.