<?php
declare(strict_types=1);

namespace PpPhp\Core\Platform\Event\Scheduler\Contracts;

use PpPhp\Core\Platform\Event\Contracts\EventInterface;
use PpPhp\Core\Platform\Event\Scheduler\ScheduledEvent;
use PpPhp\Core\Platform\Event\Scheduler\SchedulerSnapshot;
use PpPhp\Core\Platform\Event\Scheduler\SchedulerStatistics;

interface SchedulerInterface
{
    public function dispatchLater(EventInterface|string $event, int $seconds, array $payload = [], array $metadata = []): string;
    public function dispatchAfterResponse(EventInterface|string $event, array $payload = [], array $metadata = []): string;
    public function dispatchAt(EventInterface|string $event, string $dateTime, array $payload = [], array $metadata = []): string;
    public function dispatchEvery(EventInterface|string $event, string $interval, array $payload = [], array $metadata = []): string;
    public function cancel(string $id): bool;
    public function due(?string $now = null): array;
    public function run(?callable $handler = null): int;
    public function clear(): void;
    public function snapshot(): SchedulerSnapshot;
    public function restore(SchedulerSnapshot $snapshot): void;
    public function statistics(): SchedulerStatistics;
}
