mcpField
L
laravel:queues-and-horizon

laravel:queues-and-horizon

github.com/jpcaparasDevelopment157169 installsUpdated 17w ago
Repository

About laravel:queues-and-horizon

A Laravel skill for operating queues and Horizon and verifying job behavior. It covers worker commands, retry-safe job patterns, routing, observability, and tests.

Key features

  1. 01Worker and Horizon commands
  2. 02Named queue prioritization
  3. 03Retry-safe job design
  4. 04Queue routing and job attributes
  5. 05Job dispatch and integration tests

Use cases

  1. 01Run workers with queue and retry settings
  2. 02Route jobs by connection and queue policy
  3. 03Verify job dispatch and side effects
  4. 04Inspect failed jobs and queue behavior

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/jpcaparas/superpowers-laravel --skill laravel:queues-and-horizon

After installing, type/laravel:queues-and-horizonin Claude Code to confirm it loaded.

Details

From the project README

Queues and Horizon

Run workers safely, verify execution, and test job behavior.

Commands

# Start worker
sail artisan queue:work --queue=high,default --tries=3 --backoff=5   # or: php artisan queue:work --queue=high,default --tries=3 --backoff=5

# Horizon (if installed)
sail artisan horizon                                               # or: php artisan horizon

# Failed jobs
sail artisan queue:failed                                          # or: php artisan queue:failed
sail artisan queue:retry all                                       # or: php artisan queue:retry all

Patterns

  • Use named queues for prioritization; keep defaults sane
  • Add actionable Log::warning/::error with context in jobs
  • Idempotency: make jobs safe to retry
  • Emit metrics where possible; observe in Horizon or your APM

Laravel 13+

# Centralized queue routing (e.g., in AppServiceProvider)
Queue::route(ProcessPodcast::class, connection: 'redis', queue: 'podcasts');

# Declarative job controls via attributes
use Illuminate\Queue\Attributes\{Tries, Backoff, Timeout, FailOnTimeout};

#[Tries(3)]
#[Backoff([10, 30, 60])]
#[Timeout(120)]
#[FailOnTimeout]
class ProcessPodcast implements ShouldQueue { /* ... */ }

# Graceful shutdown for long-running jobs
class ProcessPodcast implements ShouldQueue, Interruptible {
    public function onInterrupt(): void { /* release locks, save state */ }
}

# Auto-scaling friendly worker exit
sail artisan queue:work --stop-when-empty-for=60   # or: php artisan queue:work --stop-when-empty-for=60
  • Prefer Queue::route() over per-dispatch onQueue() when routing is a policy, not a caller decision
  • See laravel:php-attributes for the attribute-first style trade-offs

Testing Jobs

  • Use Bus::fake() to assert dispatching in unit tests
  • Use integration tests to verify side-effects (DB/IO)

Comments

Markdown supported