1.1 KiB
1.1 KiB
Service Interface: Operation Runs
App\Services\OperationRunService
ensureRun
Idempotently creates or retrieves an active run.
public function ensureRun(
Tenant $tenant,
string $type,
array $inputs,
?User $initiator = null
): OperationRun
- Logic:
- Compute
hash = sha256(tenant_id + type + sorted_json(inputs)). - Try finding active run (
queuedorrunning) with this hash. - If found, return it.
- If not found, create new
queuedrun. - Return run.
- Compute
updateRun
Updates the status/outcome of a run.
public function updateRun(
OperationRun $run,
string $status,
?string $outcome = null,
array $summaryCounts = [],
array $failures = []
): OperationRun
failRun
Helper to fail a run immediately.
public function failRun(OperationRun $run, Throwable $e): OperationRun
App\Jobs\Middleware\TrackOperationRun
Middleware for Jobs to automatically handle running -> completed/failed transitions if bound to a run.
App\Listeners\SyncRestoreRunToOperation
Listener for RestoreRun events to update the shadow OperationRun.