Skip to main content

RepositoryUnitOfWork

Trait RepositoryUnitOfWork 

Source
pub trait RepositoryUnitOfWork: Send {
Show 42 methods // Required methods fn register_definition_upgrade<'a>( &'a mut self, job_name: &'a JobName, upgrade: &'a DefinitionUpgrade, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'a>>; fn select_or_create_job_instance<'a>( &'a mut self, key: &'a JobInstanceKey, ) -> Pin<Box<dyn Future<Output = Result<JobInstanceSelection, RepositoryError>> + Send + 'a>>; fn create_job_execution( &mut self, job_instance_id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + '_>>; fn create_job_execution_with_definition<'a>( &'a mut self, job_instance_id: JobInstanceId, definition: &'a DefinitionIdentity, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + 'a>>; fn create_step_execution<'a>( &'a mut self, job_execution_id: JobExecutionId, step_name: &'a StepName, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + 'a>>; fn transition_job_execution( &mut self, id: JobExecutionId, expected_version: ExecutionVersion, transition: LifecycleTransition, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + '_>>; fn enrich_job_exit_status<'a>( &'a mut self, id: JobExecutionId, expected_version: ExecutionVersion, exit_status: &'a ExitStatus, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + 'a>>; fn transition_step_execution( &mut self, id: StepExecutionId, expected_version: ExecutionVersion, transition: LifecycleTransition, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + '_>>; fn enrich_step_exit_status<'a>( &'a mut self, id: StepExecutionId, expected_version: ExecutionVersion, exit_status: &'a ExitStatus, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + 'a>>; fn find_job_instance<'a>( &'a mut self, key: &'a JobInstanceKey, ) -> Pin<Box<dyn Future<Output = Result<Option<JobInstance>, RepositoryError>> + Send + 'a>>; fn get_job_instance( &mut self, id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<Option<JobInstance>, RepositoryError>> + Send + '_>>; fn get_job_execution( &mut self, id: JobExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Option<JobExecution>, RepositoryError>> + Send + '_>>; fn job_executions( &mut self, job_instance_id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<Vec<JobExecution>, RepositoryError>> + Send + '_>>; fn get_step_execution( &mut self, id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Option<StepExecution>, RepositoryError>> + Send + '_>>; fn step_executions( &mut self, job_execution_id: JobExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<StepExecution>, RepositoryError>> + Send + '_>>; fn recover_job_execution<'a>( &'a mut self, id: JobExecutionId, request: &'a RecoveryRequest, ) -> Pin<Box<dyn Future<Output = Result<RecoveryResult, RepositoryError>> + Send + 'a>>; fn recovery_decision( &mut self, id: JobExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Option<RecoveryDecision>, RepositoryError>> + Send + '_>>; fn commit<'a>( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'a>> where Self: 'a; fn rollback<'a>( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'a>> where Self: 'a; // Provided methods fn create_flow_step_execution<'a>( &'a mut self, _job_execution_id: JobExecutionId, _step_name: &'a StepName, _node_id: &'a NodeId, _start_limit: StartLimit, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + 'a>> { ... } fn latest_flow_step<'a>( &'a mut self, _job_instance_id: JobInstanceId, _node_id: &'a NodeId, ) -> Pin<Box<dyn Future<Output = Result<Option<FlowStepState>, RepositoryError>> + Send + 'a>> { ... } fn append_flow_decision<'a>( &'a mut self, _request: &'a FlowDecisionRequest, ) -> Pin<Box<dyn Future<Output = Result<FlowDecision, RepositoryError>> + Send + 'a>> { ... } fn find_reusable_flow_decision<'a>( &'a mut self, _job_instance_id: JobInstanceId, _node_id: &'a NodeId, _plan_fingerprint: &'a [u8; 32], _input_digest: &'a [u8; 32], _kind: FlowTransitionKind, ) -> Pin<Box<dyn Future<Output = Result<Option<FlowDecision>, RepositoryError>> + Send + 'a>> { ... } fn flow_decisions( &mut self, _job_execution_id: JobExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<FlowDecision>, RepositoryError>> + Send + '_>> { ... } fn create_step_partition_plan<'a>( &'a mut self, _step_execution_id: StepExecutionId, _entries: &'a [PartitionPlanEntry], ) -> Pin<Box<dyn Future<Output = Result<Vec<StepPartition>, RepositoryError>> + Send + 'a>> { ... } fn step_partition_plan( &mut self, _step_execution_id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<StepPartition>, RepositoryError>> + Send + '_>> { ... } fn restart_step_partition_plan( &mut self, _source_step_execution_id: StepExecutionId, _target_step_execution_id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<StepPartition>, RepositoryError>> + Send + '_>> { ... } fn assign_step_partition( &mut self, _id: StepPartitionId, _expected_version: ExecutionVersion, _worker_step_execution_id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<StepPartition, RepositoryError>> + Send + '_>> { ... } fn complete_step_partition( &mut self, _id: StepPartitionId, _expected_version: ExecutionVersion, _worker_step_execution_id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<StepPartition, RepositoryError>> + Send + '_>> { ... } fn aggregate_step_partitions( &mut self, _step_execution_id: StepExecutionId, _expected_version: ExecutionVersion, _transitioned_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + '_>> { ... } fn find_operator_request<'a>( &'a mut self, _action: OperatorAction, _operation_id: &'a OperationId, ) -> Pin<Box<dyn Future<Output = Result<Option<OperatorRecord>, RepositoryError>> + Send + 'a>> { ... } fn append_operator_request<'a>( &'a mut self, _draft: &'a OperatorRecordDraft, ) -> Pin<Box<dyn Future<Output = Result<OperatorRecord, RepositoryError>> + Send + 'a>> { ... } fn request_execution_stop<'a>( &'a mut self, _id: JobExecutionId, _expected_version: ExecutionVersion, _actor: &'a ActorRef, _requested_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + 'a>> { ... } fn claim_execution_owner<'a>( &'a mut self, _id: JobExecutionId, _expected_version: ExecutionVersion, _owner: &'a OwnerToken, _claimed_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + 'a>> { ... } fn observe_execution_control<'a>( &'a mut self, _id: JobExecutionId, _owner: &'a OwnerToken, _observed_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<ExecutionControl, RepositoryError>> + Send + 'a>> { ... } fn job_instance_hold( &mut self, _id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<Option<RetentionHold>, RepositoryError>> + Send + '_>> { ... } fn place_instance_hold<'a>( &'a mut self, _id: JobInstanceId, _actor: &'a ActorRef, _reason: &'a ReasonCode, _placed_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<RetentionHold, RepositoryError>> + Send + 'a>> { ... } fn release_instance_hold( &mut self, _id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<Option<RetentionHold>, RepositoryError>> + Send + '_>> { ... } fn find_retention_action<'a>( &'a mut self, _action: RetentionAction, _operation_id: &'a OperationId, ) -> Pin<Box<dyn Future<Output = Result<Option<RetentionRecord>, RepositoryError>> + Send + 'a>> { ... } fn append_retention_action<'a>( &'a mut self, _draft: &'a RetentionRecordDraft, ) -> Pin<Box<dyn Future<Output = Result<RetentionRecord, RepositoryError>> + Send + 'a>> { ... } fn purge_survey<'a>( &'a mut self, _request: &'a PurgePlanRequest, ) -> Pin<Box<dyn Future<Output = Result<PurgeSurvey, RepositoryError>> + Send + 'a>> { ... } fn apply_purge<'a>( &'a mut self, _plan: &'a PurgePlan, ) -> Pin<Box<dyn Future<Output = Result<PurgeCounts, RepositoryError>> + Send + 'a>> { ... }
}
Expand description

Transaction-scoped metadata operations required by the executable kernel.

Methods borrow the unit of work for the returned future, allowing a future PostgreSQL adapter to keep its concrete transaction private. A successful operation is still provisional until commit succeeds.

Required Methods§

Source

fn register_definition_upgrade<'a>( &'a mut self, job_name: &'a JobName, upgrade: &'a DefinitionUpgrade, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'a>>

Registers one explicit directed definition compatibility edge.

Source

fn select_or_create_job_instance<'a>( &'a mut self, key: &'a JobInstanceKey, ) -> Pin<Box<dyn Future<Output = Result<JobInstanceSelection, RepositoryError>> + Send + 'a>>

Selects or creates the unique logical instance for key.

Source

fn create_job_execution( &mut self, job_instance_id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + '_>>

Creates a new launch or restart attempt for an existing instance.

A first attempt is allowed when no prior execution exists. A later attempt is allowed only after STOPPED or FAILED. Completed, abandoned, active, and unknown instances are rejected.

Source

fn create_job_execution_with_definition<'a>( &'a mut self, job_instance_id: JobInstanceId, definition: &'a DefinitionIdentity, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + 'a>>

Creates an attempt bound to an exact restart-relevant definition.

Durable adapters compare the supplied identity with the definition that produced the latest checkpoint before creating a restart attempt.

Source

fn create_step_execution<'a>( &'a mut self, job_execution_id: JobExecutionId, step_name: &'a StepName, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + 'a>>

Creates a step attempt linked to an existing job execution.

Source

fn transition_job_execution( &mut self, id: JobExecutionId, expected_version: ExecutionVersion, transition: LifecycleTransition, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + '_>>

Applies a compare-and-swap lifecycle transition to a job execution.

Source

fn enrich_job_exit_status<'a>( &'a mut self, id: JobExecutionId, expected_version: ExecutionVersion, exit_status: &'a ExitStatus, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + 'a>>

Enriches a job execution’s exit status with compare-and-swap semantics.

Source

fn transition_step_execution( &mut self, id: StepExecutionId, expected_version: ExecutionVersion, transition: LifecycleTransition, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + '_>>

Applies a compare-and-swap lifecycle transition to a step execution.

Source

fn enrich_step_exit_status<'a>( &'a mut self, id: StepExecutionId, expected_version: ExecutionVersion, exit_status: &'a ExitStatus, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + 'a>>

Enriches a step execution’s exit status with compare-and-swap semantics.

Source

fn find_job_instance<'a>( &'a mut self, key: &'a JobInstanceKey, ) -> Pin<Box<dyn Future<Output = Result<Option<JobInstance>, RepositoryError>> + Send + 'a>>

Finds a job instance by its canonical identifying key.

Source

fn get_job_instance( &mut self, id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<Option<JobInstance>, RepositoryError>> + Send + '_>>

Loads one job instance snapshot by its opaque identifier.

Source

fn get_job_execution( &mut self, id: JobExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Option<JobExecution>, RepositoryError>> + Send + '_>>

Loads one job execution snapshot for inspection.

Source

fn job_executions( &mut self, job_instance_id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<Vec<JobExecution>, RepositoryError>> + Send + '_>>

Loads job execution snapshots in creation order.

Source

fn get_step_execution( &mut self, id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Option<StepExecution>, RepositoryError>> + Send + '_>>

Loads one step execution snapshot for inspection.

Source

fn step_executions( &mut self, job_execution_id: JobExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<StepExecution>, RepositoryError>> + Send + '_>>

Loads step execution snapshots in creation order.

Source

fn recover_job_execution<'a>( &'a mut self, id: JobExecutionId, request: &'a RecoveryRequest, ) -> Pin<Box<dyn Future<Output = Result<RecoveryResult, RepositoryError>> + Send + 'a>>

Atomically resolves one orphaned or ambiguous execution and appends its audit record.

Source

fn recovery_decision( &mut self, id: JobExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Option<RecoveryDecision>, RepositoryError>> + Send + '_>>

Loads the append-only recovery decision for one execution, when present.

Source

fn commit<'a>( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'a>>
where Self: 'a,

Atomically publishes all changes made by this unit of work.

Source

fn rollback<'a>( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = Result<(), RepositoryError>> + Send + 'a>>
where Self: 'a,

Explicitly rolls back this unit of work.

Dropping a unit of work has the same metadata effect.

Provided Methods§

Source

fn create_flow_step_execution<'a>( &'a mut self, _job_execution_id: JobExecutionId, _step_name: &'a StepName, _node_id: &'a NodeId, _start_limit: StartLimit, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + 'a>>

Atomically checks an instance-wide start limit and creates one logical step attempt.

Entering STARTING consumes one start. The logical ID is independent of the display/durable step name and is the restart authority for a format-2 plan.

Source

fn latest_flow_step<'a>( &'a mut self, _job_instance_id: JobInstanceId, _node_id: &'a NodeId, ) -> Pin<Box<dyn Future<Output = Result<Option<FlowStepState>, RepositoryError>> + Send + 'a>>

Loads the latest durable attempt for one instance/logical-step pair.

Source

fn append_flow_decision<'a>( &'a mut self, _request: &'a FlowDecisionRequest, ) -> Pin<Box<dyn Future<Output = Result<FlowDecision, RepositoryError>> + Send + 'a>>

Appends one already plan-validated transition before its target starts.

Source

fn find_reusable_flow_decision<'a>( &'a mut self, _job_instance_id: JobInstanceId, _node_id: &'a NodeId, _plan_fingerprint: &'a [u8; 32], _input_digest: &'a [u8; 32], _kind: FlowTransitionKind, ) -> Pin<Box<dyn Future<Output = Result<Option<FlowDecision>, RepositoryError>> + Send + 'a>>

Finds a prior decision whose exact durable input may be reused.

Source

fn flow_decisions( &mut self, _job_execution_id: JobExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<FlowDecision>, RepositoryError>> + Send + '_>>

Loads one execution’s flow decisions in sequence order.

Source

fn create_step_partition_plan<'a>( &'a mut self, _step_execution_id: StepExecutionId, _entries: &'a [PartitionPlanEntry], ) -> Pin<Box<dyn Future<Output = Result<Vec<StepPartition>, RepositoryError>> + Send + 'a>>

Inserts one complete bounded partition plan before any worker starts.

Entry order becomes the stable one-based partition ordinal. The method rejects an empty, oversized, duplicate-key, or already-created plan without publishing a partial plan.

Source

fn step_partition_plan( &mut self, _step_execution_id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<StepPartition>, RepositoryError>> + Send + '_>>

Loads the complete partition plan in partition-key byte order.

Source

fn restart_step_partition_plan( &mut self, _source_step_execution_id: StepExecutionId, _target_step_execution_id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<Vec<StepPartition>, RepositoryError>> + Send + '_>>

Carries one prior attempt’s committed partition plan into a new parent.

Completed results are retained without rerunning their worker. Other results become unassigned STARTING work only after the source job has reached a restartable terminal state through ordinary failure/stop or explicit recovery. The operation publishes the complete target plan or nothing.

Source

fn assign_step_partition( &mut self, _id: StepPartitionId, _expected_version: ExecutionVersion, _worker_step_execution_id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<StepPartition, RepositoryError>> + Send + '_>>

Assigns a new or restart-eligible partition to a worker attempt by CAS.

Source

fn complete_step_partition( &mut self, _id: StepPartitionId, _expected_version: ExecutionVersion, _worker_step_execution_id: StepExecutionId, ) -> Pin<Box<dyn Future<Output = Result<StepPartition, RepositoryError>> + Send + '_>>

Publishes one assigned worker’s durable terminal snapshot by CAS.

The adapter locks and verifies the exact assigned worker. Status, exit status, and counters are derived from that worker rather than accepted from a caller-supplied result, so an active or crossed worker cannot fabricate a partition result.

Source

fn aggregate_step_partitions( &mut self, _step_execution_id: StepExecutionId, _expected_version: ExecutionVersion, _transitioned_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<StepExecution, RepositoryError>> + Send + '_>>

Aggregates every durable child and atomically terminates its parent step.

The adapter reads the complete plan, derives the fixed key-ordered aggregate, and updates status, exit status, counters, failure, timestamp, and optimistic version in this unit of work. An active child prevents any parent mutation.

Source

fn find_operator_request<'a>( &'a mut self, _action: OperatorAction, _operation_id: &'a OperationId, ) -> Pin<Box<dyn Future<Output = Result<Option<OperatorRecord>, RepositoryError>> + Send + 'a>>

Reads the recorded outcome of one (action, operation id) pair.

An adapter without durable operator audit rejects the capability rather than inferring idempotency from timing or request similarity.

Source

fn append_operator_request<'a>( &'a mut self, _draft: &'a OperatorRecordDraft, ) -> Pin<Box<dyn Future<Output = Result<OperatorRecord, RepositoryError>> + Send + 'a>>

Appends one operator audit row in the transaction of its effect.

Source

fn request_execution_stop<'a>( &'a mut self, _id: JobExecutionId, _expected_version: ExecutionVersion, _actor: &'a ActorRef, _requested_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + 'a>>

Records a durable stop request under compare-and-swap.

The request does not transition the execution. The owning runtime observes it at the next chunk-commit boundary and at least once per its configured poll interval.

Source

fn claim_execution_owner<'a>( &'a mut self, _id: JobExecutionId, _expected_version: ExecutionVersion, _owner: &'a OwnerToken, _claimed_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<JobExecution, RepositoryError>> + Send + 'a>>

Claims one newly created STARTING execution for the current process.

The token is evidence rather than a lease. A different recorded token rejects the claim and never authorizes takeover of an existing attempt.

Source

fn observe_execution_control<'a>( &'a mut self, _id: JobExecutionId, _owner: &'a OwnerToken, _observed_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<ExecutionControl, RepositoryError>> + Send + 'a>>

Observes a durable stop request as the owning process.

When the owner matches and an active execution has a request, this call moves it to STOPPING in the same transaction. It never treats a token as a lease or takeover authority.

Source

fn job_instance_hold( &mut self, _id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<Option<RetentionHold>, RepositoryError>> + Send + '_>>

Reads the active retention hold of one logical instance.

Source

fn place_instance_hold<'a>( &'a mut self, _id: JobInstanceId, _actor: &'a ActorRef, _reason: &'a ReasonCode, _placed_at: SystemTime, ) -> Pin<Box<dyn Future<Output = Result<RetentionHold, RepositoryError>> + Send + 'a>>

Places the single retention hold of one logical instance.

Source

fn release_instance_hold( &mut self, _id: JobInstanceId, ) -> Pin<Box<dyn Future<Output = Result<Option<RetentionHold>, RepositoryError>> + Send + '_>>

Releases the retention hold of one logical instance.

Source

fn find_retention_action<'a>( &'a mut self, _action: RetentionAction, _operation_id: &'a OperationId, ) -> Pin<Box<dyn Future<Output = Result<Option<RetentionRecord>, RepositoryError>> + Send + 'a>>

Reads the recorded outcome of one retention (action, operation id).

Source

fn append_retention_action<'a>( &'a mut self, _draft: &'a RetentionRecordDraft, ) -> Pin<Box<dyn Future<Output = Result<RetentionRecord, RepositoryError>> + Send + 'a>>

Appends one retention audit row in the transaction it audits.

Source

fn purge_survey<'a>( &'a mut self, _request: &'a PurgePlanRequest, ) -> Pin<Box<dyn Future<Output = Result<PurgeSurvey, RepositoryError>> + Send + 'a>>

Surveys bounded purge candidates with the versions observed for them.

Source

fn apply_purge<'a>( &'a mut self, _plan: &'a PurgePlan, ) -> Pin<Box<dyn Future<Output = Result<PurgeCounts, RepositoryError>> + Send + 'a>>

Re-validates a plan and deletes one bounded batch in instance-owned order.

Any candidate whose eligibility or version changed produces RepositoryError::RetentionPlanStale and deletes nothing.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§