//
// Copyright (c) StellaOps. Licensed under AGPL-3.0-or-later.
//
using StellaOps.HybridLogicalClock;
namespace StellaOps.Scheduler.Queue.Hlc;
///
/// Service for HLC-ordered scheduler job dequeuing.
///
///
/// This service provides deterministic, HLC-ordered retrieval of scheduler log entries
/// for processing. The HLC ordering guarantees causal consistency across distributed nodes.
///
public interface IHlcSchedulerDequeueService
{
///
/// Dequeues scheduler log entries in HLC order.
///
/// Tenant identifier.
/// Maximum number of entries to return.
/// Optional partition key to filter by.
/// Cancellation token.
/// The dequeue result with entries in HLC order.
Task DequeueAsync(
string tenantId,
int limit,
string? partitionKey = null,
CancellationToken cancellationToken = default);
///
/// Dequeues scheduler log entries within an HLC time range.
///
/// Tenant identifier.
/// HLC range start (inclusive, null for unbounded).
/// HLC range end (inclusive, null for unbounded).
/// Maximum number of entries to return.
/// Optional partition key to filter by.
/// Cancellation token.
/// The dequeue result with entries in HLC order.
Task DequeueByRangeAsync(
string tenantId,
HlcTimestamp? startHlc,
HlcTimestamp? endHlc,
int limit,
string? partitionKey = null,
CancellationToken cancellationToken = default);
///
/// Dequeues scheduler log entries after a specific HLC timestamp (cursor-based).
///
/// Tenant identifier.
/// HLC timestamp to start after (exclusive).
/// Maximum number of entries to return.
/// Optional partition key to filter by.
/// Cancellation token.
/// The dequeue result with entries in HLC order.
Task DequeueAfterAsync(
string tenantId,
HlcTimestamp afterHlc,
int limit,
string? partitionKey = null,
CancellationToken cancellationToken = default);
///
/// Gets a single scheduler log entry by job ID.
///
/// Tenant identifier.
/// The job identifier.
/// Cancellation token.
/// The scheduler log entry if found, null otherwise.
Task GetByJobIdAsync(
string tenantId,
Guid jobId,
CancellationToken cancellationToken = default);
}