Skip to content

Add opt-in checkpoints to operations - #3

Merged
stevebauman merged 14 commits into
masterfrom
feat/operation-checkpoints
Oct 5, 2026
Merged

stevebauman merged 14 commits into
masterfrom
feat/operation-checkpoints

Conversation

@stevebauman

@stevebauman stevebauman commented Oct 5, 2026 •

Copy link
Copy Markdown
Member

Long-running operations currently have no built-in way to save progress between attempts. I've added an opt-in DirectoryTree\Operations\Concerns\HasCheckpoints trait so an operation can persist a cursor or other JSON value and read it when it runs again:

$lastId = $this->checkpoints->get('last_id', 0);

$this->checkpoints->put('last_id', $company->id);

get() reads a value with an optional default. put() saves a key and value, or an array of values, without replacing other keys. Checkpoints are scoped to the operation's filename, use the configured operations connection, and participate in its active transaction.

Applications that use HasCheckpoints can publish and run its migration separately:

php artisan vendor:publish --tag=operations-checkpoints-migration
php artisan migrate

The standard migration tag only publishes the operations table. Running, checking status, and forgetting operations work without the checkpoint table. When it exists, operations:forget also clears saved checkpoints, including progress from unfinished operations. The repository's forget() method clears only the operation's checkpoints.

Validation: 72 tests pass (336 assertions), and Pint passes locally.

@stevebauman stevebauman changed the title Add persistent checkpoints to operations Add opt-in checkpoints to operations Oct 5, 2026
@stevebauman
stevebauman merged commit b981065 into master Oct 5, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant