pub struct PollerCache { /* private fields */ }Expand description
Shared handle to the background poll cache.
Why: The Arc<RwLock<…>> is shared between the background task and every
request handler, so all handlers read from the same live snapshot without
contention.
What: Wraps an Arc<RwLock<Option<CachedSnapshot>>>. None means the
first poll has not completed yet; handlers must fall back to a suitable
loading state in that case.
Test: Constructed in start; cloned into request handlers via AppState.
Implementations§
Source§impl PollerCache
impl PollerCache
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new, empty PollerCache.
Why: Start with None so handlers can detect “first poll not done yet”.
What: Allocates the Arc<RwLock<None>>.
Test: Called by start.
Sourcepub async fn snapshot(&self) -> Option<CachedSnapshot>
pub async fn snapshot(&self) -> Option<CachedSnapshot>
Read the current snapshot (may be None on first startup).
Why: Routes call this to serve /api/console/services from cache.
What: Acquires a read lock, clones the snapshot, releases the lock.
Test: test_cache_initialises_with_connectors.
Sourcepub async fn poll_once(
&self,
connectors: Arc<Vec<Box<dyn ServiceConnector>>>,
) -> CachedSnapshot
pub async fn poll_once( &self, connectors: Arc<Vec<Box<dyn ServiceConnector>>>, ) -> CachedSnapshot
Run one poll cycle for the given connectors (passed as an Arc).
Why: Lets tests and the initial eager-load before the first HTTP request
force a synchronous poll without spinning up the background task.
What: Calls each connector’s detect() in a spawn_blocking task
(connectors are Send + Sync so the Arc can cross the thread
boundary), writes the result into the shared cache, and returns the
new snapshot.
Test: test_cache_initialises_with_connectors.
Trait Implementations§
Source§impl Clone for PollerCache
impl Clone for PollerCache
Source§fn clone(&self) -> PollerCache
fn clone(&self) -> PollerCache
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PollerCache
impl Debug for PollerCache
Auto Trait Implementations§
impl !RefUnwindSafe for PollerCache
impl !UnwindSafe for PollerCache
impl Freeze for PollerCache
impl Send for PollerCache
impl Sync for PollerCache
impl Unpin for PollerCache
impl UnsafeUnpin for PollerCache
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,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> 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