<?php

namespace App\Providers;

use App\Events\IncidentOpened;
use App\Events\MetricRecorded;
use App\Events\ServerStatusChanged;
use App\Listeners\CreateIncidentFromStatusChange;
use App\Listeners\EvaluateAlertRules;
use App\Listeners\NotifyAssigneeOfIncident;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;

class EventServiceProvider extends ServiceProvider
{
    /**
     * Listener registrations.
     *
     * MetricRecorded → evaluate threshold rules (CPU/RAM/disk) for that
     *                  subject and fire alerts when conditions are met.
     * IncidentOpened → notify the assignee + subscribers.
     * ServerStatusChanged → auto-create/auto-resolve incidents from
     *                  multi-location consensus voting.
     */
    protected $listen = [
        MetricRecorded::class => [
            EvaluateAlertRules::class,
        ],
        IncidentOpened::class => [
            NotifyAssigneeOfIncident::class,
        ],
        ServerStatusChanged::class => [
            CreateIncidentFromStatusChange::class,
        ],
    ];

    public function boot(): void
    {
        parent::boot();
    }
}
