Download the PHP package tetthys/safejob without Composer
On this page you can find all versions of the php package tetthys/safejob. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tetthys/safejob
More information about tetthys/safejob
Files in tetthys/safejob
Package safejob
Short Description Financial-grade idempotent job framework with Laravel integration
License MIT
Informations about the package safejob
Tetthys SafeJob
Tetthys SafeJob is a financial-grade job execution framework that guarantees
exactly-once success semantics even under retries, duplicate dispatches, or worker crashes.
It is designed for high-risk domains such as payments, wallets, settlements, and external side effects, and integrates naturally with Laravel 12 Queue while remaining framework-agnostic at the core.
Why SafeJob?
Laravel jobs are at-least-once by default.
This means:
- A job may run more than once
handle()may be re-executed after partial success- Side effects (payments, events, notifications) can be duplicated
SafeJob solves this by splitting execution into two strictly separated phases:
- Retry-safe work (can run many times)
- Exactly-once success effects (runs globally only once)
Execution Pipeline
Every SafeJob follows the same fixed pipeline:
`
If an exception occurs:
- If allowed by
FailurePolicy→ finalize as FAILED - Otherwise → exception is rethrown and normal Laravel retry applies
Installation
`
This will:
- Register the Laravel service provider automatically
- Install the
safe_jobstable for lease & state tracking
Core Concepts
SafeJob (Business Logic)
You implement SafeJob, not Laravel Job logic.
Rules:
perform()must be safe to run multiple timesonSucceededOnce()must assume it runs only once globally
Laravel Job Integration
Your Laravel Job becomes a thin adapter.
That is all.
- No manual locking
- No duplicate guards
- No custom retry logic
Failure Handling (Optional)
By default, no failure is finalized. All exceptions bubble up and Laravel retries normally.
You may define a FailurePolicy to explicitly finalize certain errors:
Only when FinalFailure is returned will the job be permanently marked as FAILED.
Guarantees
SafeJob provides:
- ✅ Global exactly-once success
- ✅ Safe retries under crashes
- ✅ Duplicate dispatch protection
- ✅ Lease-based concurrency control
- ✅ Deterministic final state (SUCCEEDED / FAILED)
What it does not do:
- ❌ Distributed transactions
- ❌ Automatic idempotency inside your domain logic
When to Use
SafeJob is ideal for:
- Payments / Wallets / Escrow
- External API side effects
- Event publishing
- Financial or legal workflows
- Any job where “running twice” is unacceptable
Design Philosophy
Jobs must be retryable. Side effects must be final. The boundary must be explicit.
SafeJob enforces this boundary by design.
License
MIT
All versions of safejob with dependencies
illuminate/support Version ^12.0
illuminate/database Version ^12.0
illuminate/console Version ^12.0