<?php

namespace MintyPHP\Repository\Scheduler;

interface ScheduledJobRepositoryInterface
{
    public function create(array $data): int|false;

    public function find(int $id): ?array;

    public function findByKey(string $jobKey): ?array;

    public function listPaged(array $filters): array;

    public function listDueJobs(string $nowUtc, int $limit = 20): array;

    public function updateJobMeta(int $id, array $data): bool;

    public function markRunning(int $id, string $startedAtUtc): bool;

    public function finishRun(
        int $id,
        string $status,
        string $startedAtUtc,
        string $finishedAtUtc,
        ?string $nextRunAtUtc,
        ?string $errorCode,
        ?string $errorMessage
    ): bool;
}
