Skip to content
This repository was archived by the owner on Mar 9, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
],
"require": {
"php": ">=7",
"illuminate/support": "5.5.x|5.6.x|5.7.x",
"illuminate/console": "5.5.x|5.6.x|5.7.x",
"illuminate/support": "5.5.x|5.6.x|5.7.x|5.8.x",
"illuminate/console": "5.5.x|5.6.x|5.7.x|5.8.x",
"symfony/process": "^3.2|^4"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Laravel 5.5 Async Queue Driver
# Laravel 5 Async Queue Driver

## Push a function/closure to the background.

Expand Down
15 changes: 8 additions & 7 deletions src/AsyncQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function push($job, $data = '', $queue = null)
* @param array $options
* @return mixed
*/
public function pushRaw($payload, $queue = null, array $options = array())
public function pushRaw($payload, $queue = null, array $options = [])
{
$id = parent::pushRaw($payload, $queue, $options);
$this->startProcess($id);
Expand Down Expand Up @@ -164,23 +164,24 @@ protected function getCommand($id)
protected function getPhpBinary()
{
$path = $this->binary;
if (!defined('PHP_WINDOWS_VERSION_BUILD')) {
if ( ! defined('PHP_WINDOWS_VERSION_BUILD')) {
$path = escapeshellarg($path);
}

$args = $this->binaryArgs;
if(is_array($args)){
if (is_array($args)) {
$args = implode(' ', $args);
}
return trim($path.' '.$args);

return trim($path . ' ' . $args);
}

protected function getBackgroundCommand($cmd)
{
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
return 'start /B '.$cmd.' > NUL';
} else {
return $cmd.' > /dev/null 2>&1 &';
return 'start /B ' . $cmd . ' > NUL';
}

return $cmd . ' > /dev/null 2>&1 &';
}
}
2 changes: 1 addition & 1 deletion src/AsyncServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ protected function registerAsyncConnector($manager)
*/
public function provides()
{
return array('command.queue.async');
return ['command.queue.async'];
}
}
11 changes: 6 additions & 5 deletions src/Connectors/AsyncConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Barryvdh\Queue\AsyncQueue;
use Illuminate\Queue\Connectors\DatabaseConnector;
use Illuminate\Support\Arr;

class AsyncConnector extends DatabaseConnector
{
Expand All @@ -18,13 +19,13 @@ class AsyncConnector extends DatabaseConnector
public function connect(array $config)
{
return new AsyncQueue(
$this->connections->connection(array_get($config, 'connection')),
$this->connections->connection(Arr::get($config, 'connection')),
$config['table'],
$config['queue'],
array_get($config, 'expire', 60),
array_get($config, 'binary', 'php'),
array_get($config, 'binary_args', ''),
array_get($config, 'connection_name', '')
Arr::get($config, 'expire', 60),
Arr::get($config, 'binary', 'php'),
Arr::get($config, 'binary_args', ''),
Arr::get($config, 'connection_name', '')
);
}
}
13 changes: 7 additions & 6 deletions src/Console/AsyncCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@

use Barryvdh\Queue\AsyncQueue;
use Illuminate\Console\Command;
use Illuminate\Queue\DatabaseQueue;
use Illuminate\Queue\Worker;
use Illuminate\Queue\WorkerOptions;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;

class AsyncCommand extends Command
{
Expand Down Expand Up @@ -63,9 +61,12 @@ public function handle(WorkerOptions $options)

/**
* Process the job
*
* @param string $connectionName
* @param integer $id
* @param WorkerOptions $options
*
* @throws \Throwable
*/
protected function processJob($connectionName, $id, $options)
{
Expand All @@ -90,9 +91,9 @@ protected function processJob($connectionName, $id, $options)
*/
protected function getArguments()
{
return array(
array('id', InputArgument::REQUIRED, 'The Job ID'),
array('connection', InputArgument::OPTIONAL, 'The name of connection'),
);
return [
['id', InputArgument::REQUIRED, 'The Job ID'],
['connection', InputArgument::OPTIONAL, 'The name of connection'],
];
}
}