Skip to main content

ReplayReducer

Struct ReplayReducer 

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

A reducer that applies WAL events to reconstruct state.

Implementations§

Source§

impl ReplayReducer

Source

pub fn new() -> Self

Creates a new replay reducer.

Source

pub fn get_lease(&self, run_id: &RunId) -> Option<&(String, u64)>

Returns the current lease state (owner, expiry) for a run by ID. Returns None if no lease is active for the run.

Source

pub fn get_lease_metadata(&self, run_id: &RunId) -> Option<&LeaseMetadata>

Returns the current lease metadata for a run by ID. Returns None if no lease metadata is active for the run.

Source

pub fn get_run_state(&self, run_id: &RunId) -> Option<&RunState>

Returns the current state of a run by ID.

Source

pub fn get_task(&self, task_id: &TaskId) -> Option<&TaskSpec>

Returns the current state of a task by ID.

Source

pub fn get_task_record(&self, task_id: &TaskId) -> Option<&TaskRecord>

Returns the full task record by ID.

Source

pub fn get_run_instance(&self, run_id: &RunId) -> Option<&RunInstance>

Returns the current state of a run instance by ID.

Source

pub fn get_run_history(&self, run_id: &RunId) -> Option<&[RunStateHistoryEntry]>

Returns the run state history for a run by ID.

Source

pub fn get_attempt_history( &self, run_id: &RunId, ) -> Option<&[AttemptHistoryEntry]>

Returns the attempt history for a run by ID.

Source

pub fn latest_sequence(&self) -> u64

Returns the latest sequence number that has been applied.

Source

pub fn run_count(&self) -> usize

Returns the number of runs being tracked.

Source

pub fn task_count(&self) -> usize

Returns the number of tasks being tracked.

Source

pub fn run_instances(&self) -> impl Iterator<Item = &RunInstance>

Returns an iterator over run instances and their states.

This method provides access to the run instances projection for read-only operations like stats collection.

Source

pub fn run_ids_for_task(&self, task_id: TaskId) -> Vec<RunId>

Returns run identifiers owned by the provided task in deterministic order.

Source

pub fn runs_for_task( &self, task_id: TaskId, ) -> impl Iterator<Item = &RunInstance>

Returns run instances for the provided task via the O(R_task) secondary index.

Source

pub fn is_task_canceled(&self, task_id: TaskId) -> bool

Returns true if the task is marked canceled in projection state.

Source

pub fn task_canceled_at(&self, task_id: TaskId) -> Option<u64>

Returns the task canceled timestamp, if present.

Source

pub fn is_engine_paused(&self) -> bool

Returns true when engine scheduling/dispatch is paused in projection state.

Source

pub fn engine_paused_at(&self) -> Option<u64>

Returns the timestamp of the most recent engine pause event, if any.

Source

pub fn engine_resumed_at(&self) -> Option<u64>

Returns the timestamp of the most recent engine resume event, if any.

Source

pub fn dependency_declarations( &self, ) -> impl Iterator<Item = (TaskId, &HashSet<TaskId>)> + '_

Returns the dependency declarations for gate reconstruction at bootstrap.

Provides raw prerequisite data so the dispatch loop can rebuild the DependencyGate without a circular storage → workflow dependency.

Source

pub fn parent_child_mappings( &self, ) -> impl Iterator<Item = (TaskId, TaskId)> + '_

Returns (child_task_id, parent_task_id) pairs for hierarchy reconstruction at bootstrap.

Derived from the parent_task_id field on each TaskSpec stored in the projection. The dispatch loop uses these to rebuild the HierarchyTracker without a circular storage → workflow dependency.

Source

pub fn tasks(&self) -> impl Iterator<Item = &TaskSpec>

Returns an iterator over task IDs and specs.

This method provides access to the tasks projection for read-only operations like stats collection.

Source

pub fn task_records(&self) -> impl Iterator<Item = &TaskRecord>

Returns an iterator over task records with timestamp metadata.

Source

pub fn apply(&mut self, event: &WalEvent) -> Result<(), ReplayReducerError>

Applies an event to the current state.

Source

pub fn trim_terminal_history(&mut self)

Removes history entries for runs that are in terminal state (Completed, Failed, Canceled).

This should be called after a snapshot write successfully captures the current state, since the snapshot will contain the full history for these terminal runs. Active (non-terminal) run histories are preserved intact.

Source

pub fn budgets( &self, ) -> impl Iterator<Item = (&(TaskId, BudgetDimension), &BudgetRecord)>

Returns an iterator over all budget records.

Source

pub fn get_budget( &self, task_id: &TaskId, dimension: BudgetDimension, ) -> Option<&BudgetRecord>

Returns the budget record for a specific (task, dimension) pair, if any.

Source

pub fn is_budget_exhausted( &self, task_id: TaskId, dimension: BudgetDimension, ) -> bool

Returns true when the specified budget has been exhausted.

Source

pub fn budget_allocation_exists( &self, task_id: TaskId, dimension: BudgetDimension, ) -> bool

Returns true when a budget allocation exists for the specified (task, dimension) pair.

Source

pub fn subscriptions( &self, ) -> impl Iterator<Item = (&SubscriptionId, &SubscriptionRecord)>

Returns an iterator over all subscription records.

Source

pub fn get_subscription( &self, subscription_id: &SubscriptionId, ) -> Option<&SubscriptionRecord>

Returns the subscription record for the given identifier, if any.

Source

pub fn subscription_exists(&self, subscription_id: SubscriptionId) -> bool

Returns true when the specified subscription exists in the projection.

Source

pub fn is_subscription_canceled(&self, subscription_id: SubscriptionId) -> bool

Returns true when the specified subscription has been canceled.

Source

pub fn actors(&self) -> impl Iterator<Item = (&ActorId, &ActorRecord)>

Returns an iterator over all actor records.

Source

pub fn get_actor(&self, actor_id: &ActorId) -> Option<&ActorRecord>

Returns the actor record for the given identifier, if any.

Source

pub fn is_actor_active(&self, actor_id: ActorId) -> bool

Returns true when the actor is registered and active.

Source

pub fn tenants(&self) -> impl Iterator<Item = (&TenantId, &TenantRecord)>

Returns an iterator over all tenant records.

Source

pub fn get_tenant(&self, tenant_id: &TenantId) -> Option<&TenantRecord>

Returns the tenant record for the given identifier, if any.

Source

pub fn tenant_exists(&self, tenant_id: TenantId) -> bool

Returns true when the tenant exists in the projection.

Source

pub fn get_role_assignment( &self, actor_id: ActorId, tenant_id: TenantId, ) -> Option<&RoleAssignmentRecord>

Returns the role assigned to an actor in a tenant, if any.

Source

pub fn actor_has_capability( &self, actor_id: ActorId, capability_key: &str, tenant_id: TenantId, ) -> bool

Returns true when an actor has a given capability in a tenant.

Source

pub fn role_assignments(&self) -> impl Iterator<Item = &RoleAssignmentRecord>

Returns an iterator over all ledger entry records. Returns an iterator over all role assignment records.

Source

pub fn capability_grants(&self) -> impl Iterator<Item = &CapabilityGrantRecord>

Returns an iterator over all capability grant records.

Source

pub fn ledger_entries(&self) -> impl Iterator<Item = &LedgerEntryRecord>

Trait Implementations§

Source§

impl Clone for ReplayReducer

Source§

fn clone(&self) -> ReplayReducer

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ReplayReducer

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for ReplayReducer

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl MutationProjection for ReplayReducer

Source§

type Error = ReplayReducerError

Typed projection apply error.
Source§

fn latest_sequence(&self) -> u64

Returns the latest durable sequence represented by this projection.
Source§

fn run_state(&self, run_id: &RunId) -> Option<RunState>

Returns the current run state for validation, if known.
Source§

fn task_exists(&self, task_id: TaskId) -> bool

Returns true when the task exists in current projection state.
Source§

fn is_task_canceled(&self, task_id: TaskId) -> bool

Returns true when the task is already marked canceled in projection state.
Source§

fn is_engine_paused(&self) -> bool

Returns true when engine control projection is currently paused.
Source§

fn active_attempt_id(&self, run_id: &RunId) -> Option<AttemptId>

Returns the active attempt identifier for the run, if one exists.
Source§

fn active_lease(&self, run_id: &RunId) -> Option<(String, u64)>

Returns the active lease metadata (owner, expiry) for the run, if one exists.
Source§

fn budget_allocation_exists( &self, task_id: TaskId, dimension: BudgetDimension, ) -> bool

Returns true when a budget allocation exists for the specified (task, dimension) pair.
Source§

fn subscription_exists(&self, subscription_id: SubscriptionId) -> bool

Returns true when the specified subscription exists in the projection.
Source§

fn is_subscription_canceled(&self, subscription_id: SubscriptionId) -> bool

Returns true when the specified subscription has been canceled.
Source§

fn apply_event(&mut self, event: &WalEvent) -> Result<(), Self::Error>

Applies a durable event to the in-memory projection.

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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