改进 集群
This commit is contained in:
parent
e0cdb3d45f
commit
9fb07ab438
@ -23,7 +23,7 @@ public static function isSlave(): bool
|
||||
return config('settings.node.type') === 'slave';
|
||||
}
|
||||
|
||||
public static function publish($event, $data = []): void
|
||||
public static function publish($event, $data = [], $register = true): void
|
||||
{
|
||||
/** @noinspection PhpUndefinedMethodInspection */
|
||||
Redis::publish('cluster_ready', json_encode([
|
||||
@ -37,7 +37,9 @@ public static function publish($event, $data = []): void
|
||||
'data' => $data,
|
||||
]));
|
||||
|
||||
self::registerThisNode(false);
|
||||
if ($register) {
|
||||
self::registerThisNode(false);
|
||||
}
|
||||
}
|
||||
|
||||
public static function registerThisNode($report = true): void
|
||||
@ -75,6 +77,7 @@ public static function listen(string|array $events, callable $callback, bool $ig
|
||||
ini_set('default_socket_timeout', -1);
|
||||
|
||||
Redis::subscribe('cluster_ready', function ($message) use ($events, $callback, $ignore_self) {
|
||||
echo $message;
|
||||
$message = json_decode($message, true);
|
||||
|
||||
if ($ignore_self && $message['node']['id'] === config('settings.node.id')) {
|
||||
|
Loading…
Reference in New Issue
Block a user