wip formatting

This commit is contained in:
Alex Renoki 2020-09-15 17:03:17 +03:00
parent 6755b42acf
commit 7a17d3529f
1 changed files with 19 additions and 23 deletions

View File

@ -123,7 +123,7 @@ class RedisChannelManager extends LocalChannelManager
*/ */
public function getGlobalChannels($appId): PromiseInterface public function getGlobalChannels($appId): PromiseInterface
{ {
return $this->getPublishClient()->smembers( return $this->publishClient->smembers(
$this->getRedisKey($appId, null, ['channels']) $this->getRedisKey($appId, null, ['channels'])
); );
} }
@ -382,8 +382,7 @@ class RedisChannelManager extends LocalChannelManager
); );
} }
return $this->publishClient return $this->publishClient->exec()
->exec()
->then(function ($data) use ($channelNames) { ->then(function ($data) use ($channelNames) {
return array_combine($channelNames, $data); return array_combine($channelNames, $data);
}); });
@ -553,11 +552,10 @@ class RedisChannelManager extends LocalChannelManager
*/ */
public function addConnectionToSet(ConnectionInterface $connection, $moment = null) public function addConnectionToSet(ConnectionInterface $connection, $moment = null)
{ {
$this->getPublishClient() $this->publishClient->zadd(
->zadd( $this->getRedisKey(null, null, ['sockets']),
$this->getRedisKey(null, null, ['sockets']), Carbon::parse($moment)->format('U'), "{$connection->app->id}:{$connection->socketId}"
Carbon::parse($moment)->format('U'), "{$connection->app->id}:{$connection->socketId}" );
);
} }
/** /**
@ -568,11 +566,10 @@ class RedisChannelManager extends LocalChannelManager
*/ */
public function removeConnectionFromSet(ConnectionInterface $connection) public function removeConnectionFromSet(ConnectionInterface $connection)
{ {
$this->getPublishClient() $this->publishClient->zrem(
->zrem( $this->getRedisKey(null, null, ['sockets']),
$this->getRedisKey(null, null, ['sockets']), "{$connection->app->id}:{$connection->socketId}"
"{$connection->app->id}:{$connection->socketId}" );
);
} }
/** /**
@ -585,14 +582,13 @@ class RedisChannelManager extends LocalChannelManager
*/ */
public function getConnectionsFromSet(int $start = 0, int $stop = 0) public function getConnectionsFromSet(int $start = 0, int $stop = 0)
{ {
return $this->getPublishClient() return $this->publishClient->zrange(
->zrange( $this->getRedisKey(null, null, ['sockets']),
$this->getRedisKey(null, null, ['sockets']), $start, $stop, 'withscores'
$start, $stop, 'withscores' )
) ->then(function ($list) {
->then(function ($list) { return Helpers::redisListToArray($list);
return Helpers::redisListToArray($list); });
});
} }
/** /**
@ -604,7 +600,7 @@ class RedisChannelManager extends LocalChannelManager
*/ */
public function addChannelToSet($appId, string $channel) public function addChannelToSet($appId, string $channel)
{ {
return $this->getPublishClient()->sadd( return $this->publishClient->sadd(
$this->getRedisKey($appId, null, ['channels']), $this->getRedisKey($appId, null, ['channels']),
$channel $channel
); );
@ -619,7 +615,7 @@ class RedisChannelManager extends LocalChannelManager
*/ */
public function removeChannelFromSet($appId, string $channel) public function removeChannelFromSet($appId, string $channel)
{ {
return $this->getPublishClient()->srem( return $this->publishClient->srem(
$this->getRedisKey($appId, null, ['channels']), $this->getRedisKey($appId, null, ['channels']),
$channel $channel
); );