Files
lotteryLaravel/app/Console/Commands/LotteryHallCountdownCommand.php
kang f0e0966a73
Some checks failed
lotterLaravel CI / test (push) Has been cancelled
lotterLaravel E2E / e2e-api (push) Has been cancelled
fix(lottery): 增加广播任务时效保护并强化命令异常处理
- 为多个广播事件添加 retryUntil 方法,设置派发后 30 秒内必须执行,否则丢弃
- 修改 LotteryDrawTickCommand handle,添加异常捕获及错误日志,保证失败时返回 FAILURE
- 修改 LotteryHallCountdownCommand handle,添加异常捕获及错误日志,超时情况写入警告日志
- 针对 SettlementOrchestrator 和 DrawHallSnapshotBuilder 查询结果添加限制,防止数据量过大
- 调整计划任务 withoutOverlapping 调用,增加 expiresAt 参数避免任务锁死
- 更新 .env.example,完善本地开发与生产环境部署说明及日志配置说明
- 移除 e2e 相关测试代码、配置及依赖,精简项目体积
2026-07-07 13:37:05 +08:00

36 lines
1.2 KiB
PHP
Raw Permalink 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
{
try {
$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;
} catch (\Throwable $e) {
report($e);
return self::FAILURE;
}
}
}