- How do I handle long-running AWS Rekognition tasks in Laravel without blocking HTTP requests?
- Use the `LongRunningTask` class to poll Rekognition’s status endpoint asynchronously. Define a custom task class extending `LongRunningTask`, implement the `check()` method to evaluate task completion, and return `TaskResult::StopChecking` when done. The package handles retries and state management automatically.
- What Laravel versions does this package support?
- This package is officially supported for Laravel 9 and 10. It requires PHP 8.1+ and leverages Laravel’s native queue and event systems, so ensure your app meets those requirements before installation.
- Can I customize the polling interval for external APIs with rate limits?
- Yes, the default polling interval is 10 seconds but can be adjusted in the config file (`default_check_frequency_in_seconds`). For APIs with strict rate limits, reduce this value or implement throttling logic inside your `check()` method.
- How do I handle failed tasks or API timeouts?
- Failed tasks are logged and can be retried automatically. Use Laravel’s queue failure system (e.g., `failed_jobs` table) to debug issues. For critical failures, extend the package to dispatch notifications or move tasks to a dead-letter queue.
- Does this package work with Redis or SQS queues?
- Yes, the package is queue-agnostic and supports Laravel’s built-in queue drivers, including Redis and SQS. Configure your queue connection in Laravel’s `.env` file, and the package will use it seamlessly for task execution.
- How can I monitor long-running task progress in production?
- Integrate with Laravel Horizon for Redis-based queues to visualize task statuses, retries, and failures. For database queues, query the `long_running_task_log_items` table directly or build a custom dashboard using the task metadata stored there.
- Is there a way to test this package without hitting real external APIs?
- Yes, the package includes utilities for mocking external API responses. Use Laravel’s HTTP client mocking or create a fake `LongRunningTaskLogItem` in tests to simulate task states (e.g., pending, completed, or failed).
- What happens if an external API returns inconsistent states (e.g., flaky responses)?
- The package retries failed checks by default, but you can customize retry logic in your task class. For idempotent operations, ensure your `check()` method handles duplicate executions gracefully, such as by checking task metadata before processing.
- Can I use this package for real-time updates instead of polling?
- No, this package is designed for polling-based workflows. If your external service supports webhooks, consider using Laravel Echo or Pusher for real-time updates instead. Polling is only suitable for APIs that lack webhook support.
- How do I scale this for high-volume task processing?
- Scale by running multiple queue workers (e.g., `php artisan queue:work --daemon`) and using a robust queue driver like Redis or SQS. Monitor queue backlogs with Laravel Horizon, and consider implementing task batching or horizontal scaling for extreme loads.