Files
lotteryLaravel/app/Console/Commands/LotteryHallCountdownCommand.php

31 lines
1.0 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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;
}
}