Skip to content
This repository was archived by the owner on Feb 7, 2024. It is now read-only.

Commit aebc38f

Browse files
committed
Moved $serverId to local channel manager
1 parent 01e3b67 commit aebc38f

File tree

2 files changed

+20
-19
lines changed

2 files changed

+20
-19
lines changed

src/ChannelManagers/LocalChannelManager.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ class LocalChannelManager implements ChannelManager
5353
*/
5454
protected $store;
5555

56+
/**
57+
* The unique server identifier.
58+
*
59+
* @var string
60+
*/
61+
protected $serverId;
62+
5663
/**
5764
* The lock name to use on Array to avoid multiple
5865
* actions that might lead to multiple processings.
@@ -71,6 +78,7 @@ class LocalChannelManager implements ChannelManager
7178
public function __construct(LoopInterface $loop, $factoryClass = null)
7279
{
7380
$this->store = new ArrayStore;
81+
$this->serverId = Str::uuid()->toString();
7482
}
7583

7684
/**
@@ -509,6 +517,16 @@ protected function getChannelClassName(string $channelName): string
509517
return Channel::class;
510518
}
511519

520+
/**
521+
* Get the unique identifier for the server.
522+
*
523+
* @return string
524+
*/
525+
public function getServerId(): string
526+
{
527+
return $this->serverId;
528+
}
529+
512530
/**
513531
* Get a new ArrayLock instance to avoid race conditions.
514532
*

src/ChannelManagers/RedisChannelManager.php

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ class RedisChannelManager extends LocalChannelManager
2626
*/
2727
protected $loop;
2828

29-
/**
30-
* The unique server identifier.
31-
*
32-
* @var string
33-
*/
34-
protected $serverId;
35-
3629
/**
3730
* The pub client.
3831
*
@@ -71,6 +64,8 @@ class RedisChannelManager extends LocalChannelManager
7164
*/
7265
public function __construct(LoopInterface $loop, $factoryClass = null)
7366
{
67+
parent::construct($loop, $factoryClass);
68+
7469
$this->loop = $loop;
7570

7671
$this->redis = Redis::connection(
@@ -88,8 +83,6 @@ public function __construct(LoopInterface $loop, $factoryClass = null)
8883
$this->subscribeClient->on('message', function ($channel, $payload) {
8984
$this->onMessage($channel, $payload);
9085
});
91-
92-
$this->serverId = Str::uuid()->toString();
9386
}
9487

9588
/**
@@ -538,16 +531,6 @@ public function getRedisClient()
538531
return $this->getPublishClient();
539532
}
540533

541-
/**
542-
* Get the unique identifier for the server.
543-
*
544-
* @return string
545-
*/
546-
public function getServerId(): string
547-
{
548-
return $this->serverId;
549-
}
550-
551534
/**
552535
* Increment the subscribed count number.
553536
*

0 commit comments

Comments
 (0)