pub struct ReplayReducer { /* private fields */ }Expand description
A reducer that applies WAL events to reconstruct state.
Implementations§
Source§impl ReplayReducer
impl ReplayReducer
Sourcepub fn get_lease(&self, run_id: &RunId) -> Option<&(String, u64)>
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.
Sourcepub fn get_lease_metadata(&self, run_id: &RunId) -> Option<&LeaseMetadata>
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.
Sourcepub fn get_run_state(&self, run_id: &RunId) -> Option<&RunState>
pub fn get_run_state(&self, run_id: &RunId) -> Option<&RunState>
Returns the current state of a run by ID.
Sourcepub fn get_task(&self, task_id: &TaskId) -> Option<&TaskSpec>
pub fn get_task(&self, task_id: &TaskId) -> Option<&TaskSpec>
Returns the current state of a task by ID.
Sourcepub fn get_task_record(&self, task_id: &TaskId) -> Option<&TaskRecord>
pub fn get_task_record(&self, task_id: &TaskId) -> Option<&TaskRecord>
Returns the full task record by ID.
Sourcepub fn get_run_instance(&self, run_id: &RunId) -> Option<&RunInstance>
pub fn get_run_instance(&self, run_id: &RunId) -> Option<&RunInstance>
Returns the current state of a run instance by ID.
Sourcepub fn get_run_history(&self, run_id: &RunId) -> Option<&[RunStateHistoryEntry]>
pub fn get_run_history(&self, run_id: &RunId) -> Option<&[RunStateHistoryEntry]>
Returns the run state history for a run by ID.
Sourcepub fn get_attempt_history(
&self,
run_id: &RunId,
) -> Option<&[AttemptHistoryEntry]>
pub fn get_attempt_history( &self, run_id: &RunId, ) -> Option<&[AttemptHistoryEntry]>
Returns the attempt history for a run by ID.
Sourcepub fn latest_sequence(&self) -> u64
pub fn latest_sequence(&self) -> u64
Returns the latest sequence number that has been applied.
Sourcepub fn task_count(&self) -> usize
pub fn task_count(&self) -> usize
Returns the number of tasks being tracked.
Sourcepub fn run_instances(&self) -> impl Iterator<Item = &RunInstance>
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.
Sourcepub fn run_ids_for_task(&self, task_id: TaskId) -> Vec<RunId>
pub fn run_ids_for_task(&self, task_id: TaskId) -> Vec<RunId>
Returns run identifiers owned by the provided task in deterministic order.
Sourcepub fn runs_for_task(
&self,
task_id: TaskId,
) -> impl Iterator<Item = &RunInstance>
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.
Sourcepub fn is_task_canceled(&self, task_id: TaskId) -> bool
pub fn is_task_canceled(&self, task_id: TaskId) -> bool
Returns true if the task is marked canceled in projection state.
Sourcepub fn task_canceled_at(&self, task_id: TaskId) -> Option<u64>
pub fn task_canceled_at(&self, task_id: TaskId) -> Option<u64>
Returns the task canceled timestamp, if present.
Sourcepub fn is_engine_paused(&self) -> bool
pub fn is_engine_paused(&self) -> bool
Returns true when engine scheduling/dispatch is paused in projection state.
Sourcepub fn engine_paused_at(&self) -> Option<u64>
pub fn engine_paused_at(&self) -> Option<u64>
Returns the timestamp of the most recent engine pause event, if any.
Sourcepub fn engine_resumed_at(&self) -> Option<u64>
pub fn engine_resumed_at(&self) -> Option<u64>
Returns the timestamp of the most recent engine resume event, if any.
Sourcepub fn dependency_declarations(
&self,
) -> impl Iterator<Item = (TaskId, &HashSet<TaskId>)> + '_
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.
Sourcepub fn parent_child_mappings(
&self,
) -> impl Iterator<Item = (TaskId, TaskId)> + '_
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.
Sourcepub fn tasks(&self) -> impl Iterator<Item = &TaskSpec>
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.
Sourcepub fn task_records(&self) -> impl Iterator<Item = &TaskRecord>
pub fn task_records(&self) -> impl Iterator<Item = &TaskRecord>
Returns an iterator over task records with timestamp metadata.
Sourcepub fn apply(&mut self, event: &WalEvent) -> Result<(), ReplayReducerError>
pub fn apply(&mut self, event: &WalEvent) -> Result<(), ReplayReducerError>
Applies an event to the current state.
Sourcepub fn trim_terminal_history(&mut self)
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.
Sourcepub fn budgets(
&self,
) -> impl Iterator<Item = (&(TaskId, BudgetDimension), &BudgetRecord)>
pub fn budgets( &self, ) -> impl Iterator<Item = (&(TaskId, BudgetDimension), &BudgetRecord)>
Returns an iterator over all budget records.
Sourcepub fn get_budget(
&self,
task_id: &TaskId,
dimension: BudgetDimension,
) -> Option<&BudgetRecord>
pub fn get_budget( &self, task_id: &TaskId, dimension: BudgetDimension, ) -> Option<&BudgetRecord>
Returns the budget record for a specific (task, dimension) pair, if any.
Sourcepub fn is_budget_exhausted(
&self,
task_id: TaskId,
dimension: BudgetDimension,
) -> bool
pub fn is_budget_exhausted( &self, task_id: TaskId, dimension: BudgetDimension, ) -> bool
Returns true when the specified budget has been exhausted.
Sourcepub fn budget_allocation_exists(
&self,
task_id: TaskId,
dimension: BudgetDimension,
) -> bool
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.
Sourcepub fn subscriptions(
&self,
) -> impl Iterator<Item = (&SubscriptionId, &SubscriptionRecord)>
pub fn subscriptions( &self, ) -> impl Iterator<Item = (&SubscriptionId, &SubscriptionRecord)>
Returns an iterator over all subscription records.
Sourcepub fn get_subscription(
&self,
subscription_id: &SubscriptionId,
) -> Option<&SubscriptionRecord>
pub fn get_subscription( &self, subscription_id: &SubscriptionId, ) -> Option<&SubscriptionRecord>
Returns the subscription record for the given identifier, if any.
Sourcepub fn subscription_exists(&self, subscription_id: SubscriptionId) -> bool
pub fn subscription_exists(&self, subscription_id: SubscriptionId) -> bool
Returns true when the specified subscription exists in the projection.
Sourcepub fn is_subscription_canceled(&self, subscription_id: SubscriptionId) -> bool
pub fn is_subscription_canceled(&self, subscription_id: SubscriptionId) -> bool
Returns true when the specified subscription has been canceled.
Sourcepub fn actors(&self) -> impl Iterator<Item = (&ActorId, &ActorRecord)>
pub fn actors(&self) -> impl Iterator<Item = (&ActorId, &ActorRecord)>
Returns an iterator over all actor records.
Sourcepub fn get_actor(&self, actor_id: &ActorId) -> Option<&ActorRecord>
pub fn get_actor(&self, actor_id: &ActorId) -> Option<&ActorRecord>
Returns the actor record for the given identifier, if any.
Sourcepub fn is_actor_active(&self, actor_id: ActorId) -> bool
pub fn is_actor_active(&self, actor_id: ActorId) -> bool
Returns true when the actor is registered and active.
Sourcepub fn tenants(&self) -> impl Iterator<Item = (&TenantId, &TenantRecord)>
pub fn tenants(&self) -> impl Iterator<Item = (&TenantId, &TenantRecord)>
Returns an iterator over all tenant records.
Sourcepub fn get_tenant(&self, tenant_id: &TenantId) -> Option<&TenantRecord>
pub fn get_tenant(&self, tenant_id: &TenantId) -> Option<&TenantRecord>
Returns the tenant record for the given identifier, if any.
Sourcepub fn tenant_exists(&self, tenant_id: TenantId) -> bool
pub fn tenant_exists(&self, tenant_id: TenantId) -> bool
Returns true when the tenant exists in the projection.
Sourcepub fn get_role_assignment(
&self,
actor_id: ActorId,
tenant_id: TenantId,
) -> Option<&RoleAssignmentRecord>
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.
Sourcepub fn actor_has_capability(
&self,
actor_id: ActorId,
capability_key: &str,
tenant_id: TenantId,
) -> bool
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.
Sourcepub fn role_assignments(&self) -> impl Iterator<Item = &RoleAssignmentRecord>
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.
Sourcepub fn capability_grants(&self) -> impl Iterator<Item = &CapabilityGrantRecord>
pub fn capability_grants(&self) -> impl Iterator<Item = &CapabilityGrantRecord>
Returns an iterator over all capability grant records.
pub fn ledger_entries(&self) -> impl Iterator<Item = &LedgerEntryRecord>
Trait Implementations§
Source§impl Clone for ReplayReducer
impl Clone for ReplayReducer
Source§fn clone(&self) -> ReplayReducer
fn clone(&self) -> ReplayReducer
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ReplayReducer
impl Debug for ReplayReducer
Source§impl Default for ReplayReducer
impl Default for ReplayReducer
Source§impl MutationProjection for ReplayReducer
impl MutationProjection for ReplayReducer
Source§type Error = ReplayReducerError
type Error = ReplayReducerError
Source§fn latest_sequence(&self) -> u64
fn latest_sequence(&self) -> u64
Source§fn run_state(&self, run_id: &RunId) -> Option<RunState>
fn run_state(&self, run_id: &RunId) -> Option<RunState>
Source§fn task_exists(&self, task_id: TaskId) -> bool
fn task_exists(&self, task_id: TaskId) -> bool
Source§fn is_task_canceled(&self, task_id: TaskId) -> bool
fn is_task_canceled(&self, task_id: TaskId) -> bool
Source§fn is_engine_paused(&self) -> bool
fn is_engine_paused(&self) -> bool
Source§fn active_attempt_id(&self, run_id: &RunId) -> Option<AttemptId>
fn active_attempt_id(&self, run_id: &RunId) -> Option<AttemptId>
Source§fn active_lease(&self, run_id: &RunId) -> Option<(String, u64)>
fn active_lease(&self, run_id: &RunId) -> Option<(String, u64)>
(owner, expiry) for the run, if one exists.