1, 2, 4).DB::transaction or lockForUpdate).Earmark facade/class.HasEarmarks trait for models.SELECT ... FOR UPDATE compatibility).EarmarkReserved/EarmarkUnset events for custom logic (e.g., logging, notifications).| Risk Area | Mitigation Strategy |
|---|---|
| Database Locking | Test under high concurrency; adjust lock_timeout in config. |
| Sequence Gaps | Validate unset() logic aligns with business rules (e.g., soft vs. hard deletes). |
| Migration Conflicts | Check for existing earmark_series table; handle schema conflicts proactively. |
| Performance | Monitor reserve()/unset() latency; consider caching for read-heavy use cases. |
| Recycling Logic | Define TTL policies for recycled values (e.g., "reusable after 24h"). |
user_id prefix)?Earmark to interfaces for mocking in tests.unset() operations to background jobs.FOR UPDATE locking.BEGIN IMMEDIATE).refreshDatabase() to test sequence gaps.DB::lockForUpdate() for unit tests.Earmark features (e.g., "phone extensions" → reserve()).AUTO_INCREMENT with Earmark for 1–2 sequences.unset() after checkout completion).pestphp/pest for testing).composer.json constraints).events array is configured in config/app.php..env.unset().sequenceDiagram
participant App as Application
participant Earmark as Earmark Package
participant DB as Database
App->>Earmark: reserve('phone_extensions', 1)
Earmark->>DB: START TRANSACTION
DB-->>Earmark: Lock row
Earmark->>DB: SELECT next_value
Earmark->>DB: UPDATE last_value + 1
Earmark->>DB: INSERT reservation
Earmark-->>App: 12345
App->>Earmark: unset(12345)
Earmark->>DB: DELETE reservation
Earmark->>DB: COMMIT
SELECT MAX(value)).config/earmark.php (e.g., default_ttl, lock_timeout).earmark_series table bloat (e.g., stale reservations).composer update poing/earmark.earmark_series table is small; include in DB backups.lock_timeout or optimize transaction scope.last_value and set alerts.Earmark::debug() (if available) to trace reservations.earmark_series.series_name and reserved_at columns.reserveMany() for bulk operations (e.g., pre-generating IDs).next_value for read-heavy, low-write scenarios (invalidate on reserve()).earmark_series by series_name or use database views.| Scenario | Impact | Mitigation |
|---|---|---|
| DB Lock Timeout | reserve() fails silently. |
Retry with exponential backoff. |
| Stale Reservations | Values stuck "reserved". | Add earmark:prune command. |
| Migration Failure | Schema conflicts. | Test migrations in CI. |
| High Concurrency | Throttling/deadlocks. | Adjust lock_timeout; use queues. |
| Package Bug | Undocumented gaps. | Contribute fixes; fork if needed. |
reserve()/unset() workflows.php artisan earmark:series phone_extensions).user_{id}_extension).How can I help you explore Laravel packages today?