31 lines
1.0 KiB
PHP
31 lines
1.0 KiB
PHP
<?php
|
||
|
||
namespace App\Console\Commands;
|
||
|
||
use Illuminate\Console\Command;
|
||
use Illuminate\Support\Facades\Log;
|
||
use App\Services\Draw\LotteryHallRealtimeBroadcaster;
|
||
|
||
final class LotteryHallCountdownCommand extends Command
|
||
{
|
||
protected $signature = 'lottery:hall-countdown';
|
||
|
||
protected $description = '大厅 countdown WebSocket:`draw.countdown`(按配置频率;见界面文档 §2.1)';
|
||
|
||
public function handle(LotteryHallRealtimeBroadcaster $broadcaster): int
|
||
{
|
||
$startedAt = hrtime(true);
|
||
$broadcaster->countdownPulse();
|
||
$elapsedMs = (int) round((hrtime(true) - $startedAt) / 1_000_000);
|
||
|
||
if ($elapsedMs >= (int) config('lottery.realtime_hall_countdown_warn_threshold_ms', 800)) {
|
||
Log::warning('lottery:hall-countdown exceeded warn threshold', [
|
||
'elapsed_ms' => $elapsedMs,
|
||
'threshold_ms' => (int) config('lottery.realtime_hall_countdown_warn_threshold_ms', 800),
|
||
]);
|
||
}
|
||
|
||
return self::SUCCESS;
|
||
}
|
||
}
|