<?php
declare(strict_types=1);
namespace App\Platform\Soc\Event;

use Throwable;

final class EventDispatcher
{
    public function __construct(private readonly EventStorage $storage = new EventStorage()) {}

    public function dispatch(SecurityEventRecord $event): string
    {
        try {
            $this->storage->store($event);
        } catch (Throwable) {
            $this->storage->enqueue($event);
        }
        return $event->uuid;
    }
}
