Merge pull request #14318 from annando/stats

Count inbound and outbound packets
This commit is contained in:
Tobias Diekershoff 2024-07-26 20:44:49 +02:00 committed by GitHub
commit aae004d3d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 63 additions and 0 deletions

View file

@ -4265,4 +4265,22 @@ class Item
Logger::warning('Post does not exist although it was supposed to had been fetched.', ['id' => $id, 'url' => $url, 'uid' => $uid]);
return 0;
}
public static function incrementInbound(string $network)
{
$packets = DI::keyValue()->get('stats_packets_inbound_' . $network) ?? 0;
if ($packets >= PHP_INT_MAX) {
$packets = 0;
}
DI::keyValue()->set('stats_packets_inbound_' . $network, $packets + 1);
}
public static function incrementOutbound(string $network)
{
$packets = DI::keyValue()->get('stats_packets_outbound_' . $network) ?? 0;
if ($packets >= PHP_INT_MAX) {
$packets = 0;
}
DI::keyValue()->set('stats_packets_outbound_' . $network, $packets + 1);
}
}