Skip to main content

ProjectionTracker

Struct ProjectionTracker 

Source
pub struct ProjectionTracker { /* private fields */ }
Expand description

Projection lifecycle tracker.

Tracks the health and staleness metadata of all projections. Projections are identified by ProjectionId which includes scope.

§Authority: Observability only, NOT orchestration

This tracker is a passive bookkeeping / observability component. It records state transitions (build, invalidation, failure) so that callers can inspect projection health and decide whether to trigger rebuilds. Current methods emit Healthy, Stale, and Missing; other ProjectionHealth variants remain reserved for compatibility and external orchestration surfaces. The tracker does NOT:

  • Schedule or execute projection rebuilds
  • Retry failed builds automatically
  • Communicate with upstream import pipelines
  • Own any source of truth

Callers are responsible for executing rebuilds and reporting outcomes via record_build() / record_failure().

Implementations§

Source§

impl ProjectionTracker

Source

pub fn new(staleness_threshold_secs: u64) -> Self

Source

pub fn record_build( &mut self, id: ProjectionId, source_count: usize, build_duration_ms: u64, version: Option<ProjectionVersion>, )

Record that a projection was successfully built.

This is a bookkeeping method, not a rebuild trigger. The tracker records that a build occurred but does not execute, schedule, or orchestrate any rebuild work. External callers must drive the actual rebuild and call this method to report the outcome.

Source

pub fn record_failure(&mut self, id: ProjectionId, error: String)

Record that a projection build failed.

This is a bookkeeping method, not a retry trigger. The tracker records the failure but does not retry, schedule, or orchestrate any rebuild attempt. External callers must decide whether and when to retry, and call record_build() or record_failure() to report the next outcome.

Source

pub fn invalidate( &mut self, event: &InvalidationEvent, ) -> ProjectionActionResult

Process an invalidation event, marking affected projections as stale.

Source

pub fn invalidate_by_kind_and_scope( &mut self, kind: &ProjectionKind, scope: &ScopeKey, cause: StaleCause, ) -> ProjectionActionResult

Invalidate all projections of a given kind within a scope.

Source

pub fn invalidate_scope( &mut self, scope: &ScopeKey, cause: StaleCause, ) -> ProjectionActionResult

Invalidate all projections within a scope (all kinds).

Source

pub fn health(&self, id: &ProjectionId) -> ProjectionHealth

Get the health of a specific projection (with time-based staleness check).

Source

pub fn get(&self, id: &ProjectionId) -> Option<&ProjectionMeta>

Get metadata for a specific projection.

Source

pub fn all_ids(&self) -> impl Iterator<Item = &ProjectionId>

Iterate over all tracked projection IDs.

Useful for external rebuild drivers that need to scan for stale projections.

Source

pub fn query_status( &self, kind: Option<&ProjectionKind>, scope: Option<&ScopeKey>, ) -> Vec<&ProjectionMeta>

Query status of all projections matching a kind and/or scope filter.

Source

pub fn list(&self) -> Vec<&ProjectionMeta>

List all tracked projections.

Source

pub fn remove(&mut self, id: &ProjectionId) -> Option<ProjectionMeta>

Remove a projection from tracking (forces recomputation on next access).

Source

pub fn clear_scope(&mut self, scope: &ScopeKey) -> ProjectionActionResult

Clear all projections within a scope.

Trait Implementations§

Source§

impl Debug for ProjectionTracker

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more