改名
This commit is contained in:
@@ -9,7 +9,6 @@ use HttpServer\Abstracts\Callback;
|
||||
use Kafka\Struct;
|
||||
use Snowflake\Crontab\Crontab;
|
||||
use Snowflake\Event;
|
||||
use Snowflake\Exception\ComponentException;
|
||||
use Swoole\Server;
|
||||
|
||||
/**
|
||||
@@ -50,6 +49,10 @@ class OnPipeMessage extends Callback
|
||||
{
|
||||
/** @var Crontab $crontab */
|
||||
$crontab = $message['handler'] ?? null;
|
||||
if (!isset($message['handler'])) {
|
||||
throw new Exception('unknown handler');
|
||||
}
|
||||
$crontab = swoole_unserialize($crontab['handler']);
|
||||
$crontab->increment()->execute();
|
||||
return 'success';
|
||||
}
|
||||
|
||||
@@ -5,12 +5,12 @@ namespace Snowflake\Crontab;
|
||||
|
||||
|
||||
use Exception;
|
||||
use Snowflake\Cache\Redis;
|
||||
use Snowflake\Process\Process;
|
||||
use Snowflake\Snowflake;
|
||||
use Swoole\Coroutine\WaitGroup;
|
||||
use Swoole\Coroutine\Channel;
|
||||
use Swoole\Coroutine\WaitGroup;
|
||||
use Swoole\Timer;
|
||||
use Snowflake\Cache\Redis;
|
||||
|
||||
/**
|
||||
* Class Zookeeper
|
||||
@@ -65,9 +65,14 @@ class Zookeeper extends Process
|
||||
*/
|
||||
private function dispatch($server, Redis|\Redis $redis, int $setting, $value)
|
||||
{
|
||||
$server->sendMessage([
|
||||
'action' => 'crontab', 'handler' => swoole_unserialize($redis->get('crontab:' . $value))
|
||||
], random_int(0, $setting - 1));
|
||||
try {
|
||||
$params['action'] = 'crontab';
|
||||
$params['handler'] = $redis->get('crontab:' . $value);
|
||||
$server->sendMessage($params, random_int(0, $setting - 1));
|
||||
} catch (\Throwable $exception) {
|
||||
logger()->addError($exception);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user