Fixed statistics logger

This commit is contained in:
Alex Renoki 2020-09-05 22:41:02 +03:00
parent ca4a9a180e
commit 593c48f8c2
1 changed files with 4 additions and 4 deletions

View File

@ -86,13 +86,13 @@ class RedisStatisticsLogger implements StatisticsLogger
$incremented = $this->ensureAppIsSet($appId) $incremented = $this->ensureAppIsSet($appId)
->__call('hincrby', [$this->getHash($appId), 'current_connection_count', 1]); ->__call('hincrby', [$this->getHash($appId), 'current_connection_count', 1]);
$incremented->then(function ($currentConnectionCount) { $incremented->then(function ($currentConnectionCount) use ($appId) {
// Get the peak connections count from Redis. // Get the peak connections count from Redis.
$peakConnectionCount = $this->replicator $peakConnectionCount = $this->replicator
->getPublishClient() ->getPublishClient()
->__call('hget', [$this->getHash($appId), 'peak_connection_count']); ->__call('hget', [$this->getHash($appId), 'peak_connection_count']);
$peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount) { $peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount, $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.
@ -120,13 +120,13 @@ class RedisStatisticsLogger implements StatisticsLogger
$decremented = $this->ensureAppIsSet($appId) $decremented = $this->ensureAppIsSet($appId)
->__call('hincrby', [$this->getHash($appId), 'current_connection_count', -1]); ->__call('hincrby', [$this->getHash($appId), 'current_connection_count', -1]);
$decremented->then(function ($currentConnectionCount) { $decremented->then(function ($currentConnectionCount) use ($appId) {
// Get the peak connections count from Redis. // Get the peak connections count from Redis.
$peakConnectionCount = $this->replicator $peakConnectionCount = $this->replicator
->getPublishClient() ->getPublishClient()
->__call('hget', [$this->getHash($appId), 'peak_connection_count']); ->__call('hget', [$this->getHash($appId), 'peak_connection_count']);
$peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount) { $peakConnectionCount->then(function ($currentPeakConnectionCount) use ($currentConnectionCount, $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.