<?php

namespace MintyPHP\Repository\Support;

/** Contract for database-level session control: advisory locks and transaction management. */
interface DatabaseSessionRepositoryInterface
{
    public function acquireAdvisoryLock(string $lockName, int $timeoutSeconds = 0): bool;

    public function releaseAdvisoryLock(string $lockName): void;

    public function beginTransaction(): void;

    public function commitTransaction(): void;

    public function rollbackTransaction(): void;

    /**
     * @template T
     * @param callable(): T $callback
     * @return T
     */
    public function transaction(callable $callback): mixed;
}
