pub struct FetcherState { /* private fields */ }Expand description
Logical state for Git fetches happening in the node.
A fetch can either be:
ActiveFetch: meaning it is currently being fetched from another node on the networkQueuedFetch: meaning it is expected to be fetched from a given node, but the repository is already being fetched, or the node is at capacity.
For any given repository, identified by its RepoId, there can only be
one fetch occurring for it at a given time. This prevents any concurrent
fetches from clobbering overlapping references.
If the repository is actively being fetched, then that fetch will be queued for a later attempt.
For any given node, there is a configurable capacity so that only N number
of fetches can happen with it concurrently. This does not guarantee that the
node will actually allow this node to fetch from it – since it will maintain
its own capacity for connections and load.
Implementations§
Source§impl FetcherState
impl FetcherState
Sourcepub fn new(config: Config) -> Self
pub fn new(config: Config) -> Self
Initialize the FetcherState with the given Config.
Source§impl FetcherState
impl FetcherState
Sourcepub fn handle(&mut self, command: Command) -> Event
pub fn handle(&mut self, command: Command) -> Event
Process the handling of a Command, delegating to its corresponding
method, and returning the corresponding Event.
This method is useful if the FetcherState is used in batch
processing and does need to be explicit about the underlying method.
Sourcepub fn fetch(&mut self, _: Fetch) -> Fetch
pub fn fetch(&mut self, _: Fetch) -> Fetch
Process a Fetch command, which transitions the given fetch to
active, if possible.
The fetch will only transition to being active if:
- A fetch is not already happening for that repository, in which case it gets queued.
- The node to be fetched from is not already at capacity, again it will be queued.
Sourcepub fn fetched(&mut self, _: Fetched) -> Fetched
pub fn fetched(&mut self, _: Fetched) -> Fetched
Process a Fetched command, which removes the given fetch from the set of active fetches.
Note that this is agnostic of whether the fetch succeeded or failed.
The caller will be notified if the completed fetch did not exist in the active set.
Sourcepub fn dequeue(&mut self, from: &NodeId) -> Option<QueuedFetch>
pub fn dequeue(&mut self, from: &NodeId) -> Option<QueuedFetch>
Attempt to dequeue a QueuedFetch for the given node.
This will only dequeue the fetch if it is not active, and the given node is not at capacity.
Source§impl FetcherState
impl FetcherState
Sourcepub fn queued_fetches(&self) -> &BTreeMap<NodeId, Queue>
pub fn queued_fetches(&self) -> &BTreeMap<NodeId, Queue>
Get the set of queued fetches.
Sourcepub fn active_fetches(&self) -> &BTreeMap<RepoId, ActiveFetch>
pub fn active_fetches(&self) -> &BTreeMap<RepoId, ActiveFetch>
Get the set of active fetches.
Sourcepub fn get_active_fetch(&self, rid: &RepoId) -> Option<&ActiveFetch>
pub fn get_active_fetch(&self, rid: &RepoId) -> Option<&ActiveFetch>
Get the ActiveFetch for the provided RepoId, returning None if
it does not exist.
Trait Implementations§
Source§impl Clone for FetcherState
impl Clone for FetcherState
Source§fn clone(&self) -> FetcherState
fn clone(&self) -> FetcherState
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FetcherState
impl Debug for FetcherState
Source§impl Default for FetcherState
impl Default for FetcherState
Source§impl PartialEq for FetcherState
impl PartialEq for FetcherState
Source§impl Serialize for FetcherState
impl Serialize for FetcherState
impl Eq for FetcherState
impl StructuralPartialEq for FetcherState
Auto Trait Implementations§
impl Freeze for FetcherState
impl RefUnwindSafe for FetcherState
impl Send for FetcherState
impl Sync for FetcherState
impl Unpin for FetcherState
impl UnsafeUnpin for FetcherState
impl UnwindSafe for FetcherState
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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