<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\Cache;

class OperationsSchedulerHeartbeat extends Command
{
    public const CACHE_KEY = 'operations:scheduler-heartbeat';

    protected $signature = 'operations:scheduler-heartbeat';

    protected $description = 'Record a scheduler heartbeat for production liveness verification';

    public function handle(): int
    {
        $timestamp = now()->utc()->toIso8601String();

        Cache::put(self::CACHE_KEY, $timestamp, now()->addMinutes(10));

        $this->line($timestamp);

        return self::SUCCESS;
    }
}
