Reduced the number of lines
This commit is contained in:
parent
ed41ad5ca0
commit
9c19546faf
|
|
@ -162,13 +162,9 @@ class RedisChannelManager extends LocalChannelManager
|
||||||
|
|
||||||
$this->addConnectionToSet($connection, Carbon::now());
|
$this->addConnectionToSet($connection, Carbon::now());
|
||||||
|
|
||||||
$this->addChannelToSet(
|
$this->addChannelToSet($connection->app->id, $channelName);
|
||||||
$connection->app->id, $channelName
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->incrementSubscriptionsCount(
|
$this->incrementSubscriptionsCount($connection->app->id, $channelName, 1);
|
||||||
$connection->app->id, $channelName, 1
|
|
||||||
);
|
|
||||||
|
|
||||||
parent::subscribeToChannel($connection, $channelName, $payload);
|
parent::subscribeToChannel($connection, $channelName, $payload);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,10 +56,7 @@ class RedisCollector extends MemoryCollector
|
||||||
public function webSocketMessage($appId)
|
public function webSocketMessage($appId)
|
||||||
{
|
{
|
||||||
$this->ensureAppIsInSet($appId)
|
$this->ensureAppIsInSet($appId)
|
||||||
->hincrby(
|
->hincrby($this->channelManager->getRedisKey($appId, null, ['stats']), 'websocket_messages_count', 1);
|
||||||
$this->channelManager->getRedisKey($appId, null, ['stats']),
|
|
||||||
'websocket_messages_count', 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -71,10 +68,7 @@ class RedisCollector extends MemoryCollector
|
||||||
public function apiMessage($appId)
|
public function apiMessage($appId)
|
||||||
{
|
{
|
||||||
$this->ensureAppIsInSet($appId)
|
$this->ensureAppIsInSet($appId)
|
||||||
->hincrby(
|
->hincrby($this->channelManager->getRedisKey($appId, null, ['stats']), 'api_messages_count', 1);
|
||||||
$this->channelManager->getRedisKey($appId, null, ['stats']),
|
|
||||||
'api_messages_count', 1
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -127,18 +121,12 @@ class RedisCollector extends MemoryCollector
|
||||||
{
|
{
|
||||||
// Decrement the current connections count by 1.
|
// Decrement the current connections count by 1.
|
||||||
$this->ensureAppIsInSet($appId)
|
$this->ensureAppIsInSet($appId)
|
||||||
->hincrby(
|
->hincrby($this->channelManager->getRedisKey($appId, null, ['stats']), 'current_connections_count', -1)
|
||||||
$this->channelManager->getRedisKey($appId, null, ['stats']),
|
|
||||||
'current_connections_count', -1
|
|
||||||
)
|
|
||||||
->then(function ($currentConnectionsCount) use ($appId) {
|
->then(function ($currentConnectionsCount) use ($appId) {
|
||||||
// Get the peak connections count from Redis.
|
// Get the peak connections count from Redis.
|
||||||
$this->channelManager
|
$this->channelManager
|
||||||
->getPublishClient()
|
->getPublishClient()
|
||||||
->hget(
|
->hget($this->channelManager->getRedisKey($appId, null, ['stats']), 'peak_connections_count')
|
||||||
$this->channelManager->getRedisKey($appId, null, ['stats']),
|
|
||||||
'peak_connections_count'
|
|
||||||
)
|
|
||||||
->then(function ($currentPeakConnectionCount) use ($currentConnectionsCount, $appId) {
|
->then(function ($currentPeakConnectionCount) use ($currentConnectionsCount, $appId) {
|
||||||
// Extract the greatest number between the current peak connection count
|
// Extract the greatest number between the current peak connection count
|
||||||
// and the current connection number.
|
// and the current connection number.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue