改名
This commit is contained in:
@@ -215,8 +215,9 @@ class Server extends Application
|
|||||||
if (!is_string($process)) {
|
if (!is_string($process)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$system = $application->set($process, new $process(Snowflake::app(), $name));
|
$system = new $process(Snowflake::app(), $name);
|
||||||
$this->baseServer->addProcess($system);
|
$this->baseServer->addProcess($system);
|
||||||
|
$application->set($process, $system);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-9
@@ -56,16 +56,15 @@ class Queue extends \Snowflake\Process\Process
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Process $process
|
* @param Process $process
|
||||||
* @throws ComponentException
|
|
||||||
*/
|
*/
|
||||||
public function onHandler(Process $process)
|
public function onHandler(Process $process)
|
||||||
{
|
{
|
||||||
|
Timer::tick(50, function ($timerId) {
|
||||||
$redis = Snowflake::app()->getRedis();
|
$redis = Snowflake::app()->getRedis();
|
||||||
Timer::tick(50, function ($timerId) use ($redis) {
|
|
||||||
if ($this->shutdown) {
|
if ($this->shutdown) {
|
||||||
return Timer::clear($timerId);
|
return Timer::clear($timerId);
|
||||||
}
|
}
|
||||||
$data = $redis->zRevRangeByScore(Waiting::QUEUE_WAITING, 0, 20);
|
$data = $redis->zRevRange(Waiting::QUEUE_WAITING, 0, 20);
|
||||||
if (empty($data)) {
|
if (empty($data)) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -97,11 +96,9 @@ class Queue extends \Snowflake\Process\Process
|
|||||||
*/
|
*/
|
||||||
private function scheduler($data)
|
private function scheduler($data)
|
||||||
{
|
{
|
||||||
$scheduler = new Coroutine\Scheduler();
|
|
||||||
foreach ($data as $datum) {
|
foreach ($data as $datum) {
|
||||||
$scheduler->add([$this, 'runner'], $datum);
|
$this->runner($datum);
|
||||||
}
|
}
|
||||||
$scheduler->start();
|
|
||||||
if ($this->shutdown === true) {
|
if ($this->shutdown === true) {
|
||||||
Snowflake::shutdown($this);
|
Snowflake::shutdown($this);
|
||||||
}
|
}
|
||||||
@@ -118,8 +115,8 @@ class Queue extends \Snowflake\Process\Process
|
|||||||
$logger = $this->application->getLogger();
|
$logger = $this->application->getLogger();
|
||||||
try {
|
try {
|
||||||
$rely_on = unserialize($class);
|
$rely_on = unserialize($class);
|
||||||
$this->waiting->remove($class);
|
$this->waiting->del($rely_on);
|
||||||
if ($rely_on instanceof Consumer) {
|
if (!($rely_on instanceof Consumer)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->running->add($rely_on);
|
$this->running->add($rely_on);
|
||||||
@@ -127,7 +124,7 @@ class Queue extends \Snowflake\Process\Process
|
|||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
$logger->write($exception->getMessage(), 'queue');
|
$logger->write($exception->getMessage(), 'queue');
|
||||||
} finally {
|
} finally {
|
||||||
$this->running->del($class);
|
$this->running->del($rely_on);
|
||||||
if (isset($rely_on) && $rely_on instanceof Consumer) {
|
if (isset($rely_on) && $rely_on instanceof Consumer) {
|
||||||
$rely_on->onComplete();
|
$rely_on->onComplete();
|
||||||
$this->complete->add($rely_on);
|
$this->complete->add($rely_on);
|
||||||
|
|||||||
+1
-5
@@ -38,12 +38,8 @@ class Running extends \Queue\Abstracts\Queue
|
|||||||
* @return false|int
|
* @return false|int
|
||||||
* @throws ComponentException
|
* @throws ComponentException
|
||||||
*/
|
*/
|
||||||
public function del(string $consumer)
|
public function del(Consumer $consumer)
|
||||||
{
|
{
|
||||||
$consumer = unserialize($consumer);
|
|
||||||
if (!($consumer instanceof Consumer)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return $this->pop(self::QUEUE_RUNNING, $consumer);
|
return $this->pop(self::QUEUE_RUNNING, $consumer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user