spatie/laravel-long-running-tasks
Monitor and poll external long-running jobs (e.g., AWS Rekognition) in Laravel. Define a task with a check() method that runs on a configurable interval, store meta/context, and automatically reschedule until it reports completion.
LongRunningTaskLogItem model provides auditability (status, exceptions, run count) and recovery (retries, backoff strategies), which is critical for long-running processes where failures are inevitable.MyTask::make()->meta($data)->start()), reducing onboarding time.long_running_task_log_items) with minimal overhead. No complex joins or migrations are required beyond the provided ones.keep_checking_for_in_seconds must be shorter to avoid didNotComplete false positives.meta field is a serialized array, which may not suit complex data structures (e.g., nested objects, closures). Workaround: Use JSON encoding or a separate database table.StandardBackoffCheckStrategy) may not align with all external APIs. For example, some APIs require exponential backoff with jitter, which would need a custom strategy.check() are caught and logged, but no built-in alerts (e.g., Slack, PagerDuty) are triggered. Requires additional integration (e.g., Laravel Horizon events or custom observers).keep_checking_for_in_seconds align with them?run_count, attempt) be used to track them?onFailure method suffice, or is a custom retry policy needed?LongRunningTaskLogItem queries?meta or events)?ShouldQueue or Horizon may be needed.RunLongRunningTaskJob).LongRunningTaskLogItem or use Laravel’s logging channels to track task lifecycle.LongRunningTask and LongRunningTaskLogItem for isolated testing.Queue::fake() to verify task polling behavior.VideoTranscodingTask) to validate:
config/long-running-tasks.php (e.g., queues, backoff strategies).long_running_task_log_items growth.LongRunningTaskLogItem model could conflict with existing models. Mitigation: Use the log_model config to point to a custom model.RunLongRunningTaskJob could clash with custom jobs. Mitigation: Rename or namespace the job.php artisan queue:work).composer require spatie/laravel-long-running-tasksphp artisan vendor:publish --tag="long-running-tasks-migrations"php artisan vendor:publish --tag="long-running-tasks-config"php artisan migrateApp\Tasks\BaseLongRunningTask).How can I help you explore Laravel packages today?