Moved the create record into a separate method.
This commit is contained in:
parent
aa014add21
commit
1923ceedea
|
|
@ -103,7 +103,7 @@ class MemoryStatisticsLogger implements StatisticsLogger
|
|||
continue;
|
||||
}
|
||||
|
||||
$this->driver::create($statistic->toArray());
|
||||
$this->createRecord($statistic);
|
||||
|
||||
$currentConnectionCount = $this->channelManager->getConnectionCount($appId);
|
||||
|
||||
|
|
@ -135,4 +135,15 @@ class MemoryStatisticsLogger implements StatisticsLogger
|
|||
{
|
||||
return $this->statistics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new record using the Statistic Driver.
|
||||
*
|
||||
* @param Statistic $statistic
|
||||
* @return void
|
||||
*/
|
||||
public function createRecord(Statistic $statistic)
|
||||
{
|
||||
$this->driver::create($statistic->toArray());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,12 +122,7 @@ class RedisStatisticsLogger implements StatisticsLogger
|
|||
continue;
|
||||
}
|
||||
|
||||
$this->driver::create([
|
||||
'app_id' => $appId,
|
||||
'peak_connection_count' => $statistic['peak_connection_count'] ?? 0,
|
||||
'websocket_message_count' => $statistic['websocket_message_count'] ?? 0,
|
||||
'api_message_count' => $statistic['api_message_count'] ?? 0,
|
||||
]);
|
||||
$this->createRecord($statistic);
|
||||
|
||||
$currentConnectionCount = $this->channelManager->getConnectionCount($appId);
|
||||
|
||||
|
|
@ -203,4 +198,20 @@ class RedisStatisticsLogger implements StatisticsLogger
|
|||
{
|
||||
return new RedisLock($this->redis, 'laravel-websockets:lock', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new record using the Statistic Driver.
|
||||
*
|
||||
* @param array $statistic
|
||||
* @return void
|
||||
*/
|
||||
protected function createRecord(array $statistic): void
|
||||
{
|
||||
$this->driver::create([
|
||||
'app_id' => $appId,
|
||||
'peak_connection_count' => $statistic['peak_connection_count'] ?? 0,
|
||||
'websocket_message_count' => $statistic['websocket_message_count'] ?? 0,
|
||||
'api_message_count' => $statistic['api_message_count'] ?? 0,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue