Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
chaz6chez committed Feb 12, 2024
1 parent 549ad3c commit bf0763e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
"webman/console": "^1.0",
"illuminate/redis": "^9.0 | ^10.0",
"illuminate/events": "^9.0 | ^10.0",
"illuminate/database": "^9.0 | ^10.0"
"illuminate/database": "^9.0 | ^10.0",
"monolog/monolog": "^2.0 | ^3.0"
},
"require-dev": {
"workerman/webman-framework": "^1.0",
"symfony/var-dumper": "^6.0",
"phpunit/phpunit": "^9.6",
"monolog/monolog": "^2.0"
"phpunit/phpunit": "^9.6"
},
"autoload": {
"psr-4": {
Expand Down
12 changes: 6 additions & 6 deletions src/Builders/AdaptiveBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use RedisException;
use support\Log;
use Workbunny\WebmanRqueue\Builders\Traits\AdaptiveTimerMethod;
use Workbunny\WebmanRqueue\Builders\Traits\MessageQueueMethod;
use Workbunny\WebmanRqueue\Exceptions\WebmanRqueueException;
use Workerman\Timer;
use Workerman\Worker;
Expand Down Expand Up @@ -64,7 +63,7 @@ public function onWorkerStart(Worker $worker): void
$this->adaptiveTimerCreate($this->timerInterval / 1000, function () use($worker) {
try {
// consume
$this->consume($worker);
return $this->consume($worker);
} catch (WebmanRqueueException $exception) {
Log::channel('plugin.workbunny.webman-rqueue.warning')?->warning('Consume exception. ', [
'message' => $exception->getMessage(), 'code' => $exception->getCode(),
Expand All @@ -76,6 +75,7 @@ public function onWorkerStart(Worker $worker): void
'message' => $exception->getMessage(), 'code' => $exception->getCode()
]);
}
return false;
});
}
}
Expand All @@ -86,16 +86,16 @@ public function onWorkerStop(Worker $worker): void
if($this->getConnection()) {
try {
$this->getConnection()->client()->close();
}catch (RedisException $e) {
} catch (RedisException $e) {
echo $e->getMessage() . PHP_EOL;
}
}
// 移除自适应
$this->adaptiveTimerDelete();
//
// 移除pending检查定时器
if($this->getPendingTimer()) {
Timer::del($this->getPendingTimer());
}
// 移除自适应
$this->adaptiveTimerDelete();
}

/** @inheritDoc */
Expand Down
1 change: 1 addition & 0 deletions src/Builders/Traits/AdaptiveTimerMethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ public function adaptiveTimerCreate(int $millisecond, Closure $func, mixed ...$a
EventInterface::EV_TIMER,
$callback = function (...$args) use ($func, $millisecond, $id, &$callback)
{
// 获取毫秒时间戳
$nowMilliTimestamp = intval(microtime(true) * 1000);
if (\call_user_func($func, ...$args)) {
self::$lastMessageMilliTimestamp = $nowMilliTimestamp;
Expand Down

0 comments on commit bf0763e

Please sign in to comment.