Skip to content
This repository was archived by the owner on Mar 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Refactoring.
Removes old laravel|lumen versions.
Added support for 5.6|5.7 laravel|lumen.
Added to config support for hot reload (Next PR).
  • Loading branch information
fractalzombie committed Dec 19, 2018
commit 0e160f2133c8edb6d11015e8a2495765327b4986
1 change: 0 additions & 1 deletion src/Coroutine/Connectors/MySqlConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class MySqlConnector extends BaseConnector
*/
protected function createPdoConnection($dsn, $username, $password, $options)
{
//TODO I'm thinking make it out by MysqlPool
return new SwoolePDO($dsn, $username, $password, $options);
}

Expand Down
51 changes: 30 additions & 21 deletions src/Task/SwooleTaskQueue.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

namespace SwooleTW\Http\Task;


use Exception;
use Swoole\Timer;
use Illuminate\Queue\Queue;
use Illuminate\Contracts\Queue\Queue as QueueContract;
use Illuminate\Queue\Queue;
use Swoole\Timer;

/**
* Class SwooleTaskQueue (5.7)
*/
class SwooleTaskQueue extends Queue implements QueueContract
{
/**
Expand All @@ -19,7 +23,7 @@ class SwooleTaskQueue extends Queue implements QueueContract
/**
* Create Async Task instance.
*
* @param \Swoole\Http\Server $swoole
* @param \Swoole\Http\Server $swoole
*/
public function __construct($swoole)
{
Expand All @@ -29,9 +33,10 @@ public function __construct($swoole)
/**
* Push a new job onto the queue.
*
* @param string|object $job
* @param mixed $data
* @param string $queue
* @param string|object $job
* @param mixed $data
* @param string $queue
*
* @return mixed
*/
public function push($job, $data = '', $queue = null)
Expand All @@ -42,24 +47,25 @@ public function push($job, $data = '', $queue = null)
/**
* Push a raw payload onto the queue.
*
* @param string $payload
* @param string $queue
* @param array $options
* @param string $payload
* @param string $queue
* @param array $options
*
* @return mixed
*/
public function pushRaw($payload, $queue = null, array $options = [])
{
//wiki https://wiki.swoole.com/wiki/page/134.html, task($data,$dst_worker_id), $dst_worker_id should be default -1
return $this->swoole->task($payload, (!is_numeric($queue) || $queue < 0) ? -1 : (int)$queue);
return $this->swoole->task($payload, !is_numeric($queue) ? 1 : (int)$queue);
}

/**
* Push a new job onto the queue after a delay.
*
* @param \DateTimeInterface|\DateInterval|int $delay
* @param string|object $job
* @param mixed $data
* @param string $queue
* @param \DateTimeInterface|\DateInterval|int $delay
* @param string|object $job
* @param mixed $data
* @param string $queue
*
* @return mixed
*/
public function later($delay, $job, $data = '', $queue = null)
Expand All @@ -72,20 +78,22 @@ public function later($delay, $job, $data = '', $queue = null)
/**
* Create a typical, string based queue payload array.
*
* @param string $job
* @param mixed $data
* @param string $job
* @param string $queue
* @param mixed $data
*
* @throws Expcetion
* @throws \Exception
*/
protected function createStringPayload($job, $data)
protected function createStringPayload($job, $queue, $data)
{
throw new Exception('Unsupported empty data');
}

/**
* Get the size of the queue.
*
* @param string $queue
* @param string $queue
*
* @return int
*/
public function size($queue = null)
Expand All @@ -96,7 +104,8 @@ public function size($queue = null)
/**
* Pop the next job off of the queue.
*
* @param string $queue
* @param string $queue
*
* @return \Illuminate\Contracts\Queue\Job|null
*/
public function pop($queue = null)
Expand Down