This commit is contained in:
2021-04-15 18:15:23 +08:00
parent ee25cdf3af
commit 47c1ab2086
2 changed files with 10 additions and 12 deletions
+8 -9
View File
@@ -19,20 +19,19 @@ use Swoole\Server;
class OnPipeMessage extends Callback class OnPipeMessage extends Callback
{ {
/** /**
* @param Server $server * @param Server $server
* @param int $src_worker_id * @param int $src_worker_id
* @param $message * @param $swollen_universalize
* @throws Exception * @throws Exception
*/ */
public function onHandler(Server $server, int $src_worker_id, $message) public function onHandler(Server $server, int $src_worker_id, $swollen_universalize)
{ {
try { try {
$swollen_universalize = swoole_unserialize($message);
match ($swollen_universalize['action'] ?? null) { match ($swollen_universalize['action'] ?? null) {
'kafka' => $this->onKafkaWorker($swollen_universalize), 'kafka' => $this->onKafkaWorker($swollen_universalize),
'crontab' => $this->onCrontabWorker($swollen_universalize), 'crontab' => $this->onCrontabWorker($swollen_universalize),
default => $this->onMessageWorker($server, $src_worker_id, $message) default => $this->onMessageWorker($server, $src_worker_id, $swollen_universalize)
}; };
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
$this->addError($exception); $this->addError($exception);
+2 -3
View File
@@ -65,10 +65,9 @@ class Zookeeper extends Process
*/ */
private function dispatch($server, Redis|\Redis $redis, int $setting, $value) private function dispatch($server, Redis|\Redis $redis, int $setting, $value)
{ {
$server->sendMessage(swoole_serialize([ $server->sendMessage([
'action' => 'crontab', 'handler' => swoole_unserialize($redis->get('crontab:' . $value)) 'action' => 'crontab', 'handler' => swoole_unserialize($redis->get('crontab:' . $value))
]), random_int(0, $setting - 1)); ], random_int(0, $setting - 1));
$redis->del('crontab:' . $value);
} }