maxbrokman / SafeQueue

Laravel Doctrine friendly queue worker
MIT License
30 stars 28 forks source link

How to use SafeQueue with Laravel Horizon? #18

Open bigperson opened 6 years ago

bigperson commented 6 years ago

Can I use this package with Laravel Horizon?

How to start doctrine:queue:work using Laravel Horizon (Laravel 5.5 or 5.6)?

Korri commented 6 years ago

I personally replaced the horizon:work command with the following:

<?php declare(strict_types=1);

namespace App\Console\Commands;

use Laravel\Horizon\Console\WorkCommand;
use MaxBrokman\SafeQueue\Worker;

class HorizonSafeQueueWorkCommand extends WorkCommand
{
    /** @var string */
    protected $description = 'Start processing jobs on the queue as a daemon in a doctrine-safe way.';

    public function __construct(Worker $worker)
    {
        parent::__construct($worker);
    }
}

Just loads the SageQueue worker inside the Horizon queue command

dpslwk commented 4 years ago

Updated for Laravel 6, for if #24 ever gets merged

<?php

namespace App\Console\Commands;

use MaxBrokman\SafeQueue\Worker;
use Laravel\Horizon\Console\WorkCommand;
use Illuminate\Contracts\Cache\Repository as Cache;

class HorizonSafeQueueWorkCommand extends WorkCommand
{
    /**
     * @var string
     */
    protected $description = 'Start processing jobs on the queue as a daemon in a doctrine-safe way.';

    /**
     * WorkCommand constructor.
     *
     * @param Worker $worker
     * @param Cache  $cache
     */
    public function __construct(Worker $worker, Cache $cache)
    {
        parent::__construct($worker, $cache);
    }
}