//
// Copyright (c) StellaOps. Licensed under BUSL-1.1.
//
namespace StellaOps.HybridLogicalClock;
///
/// Persistent storage for HLC state (survives restarts).
///
///
///
/// Implementations should provide atomic update semantics to prevent
/// state corruption during concurrent operations. The store is used to:
///
///
/// - Persist HLC state after each tick (fire-and-forget)
/// - Recover state on node restart
/// - Ensure clock monotonicity across restarts
///
///
public interface IHlcStateStore
{
///
/// Load last persisted HLC state for node.
///
/// The node identifier to load state for.
/// Cancellation token.
/// The last persisted timestamp, or null if no state exists.
Task LoadAsync(string nodeId, CancellationToken ct = default);
///
/// Persist HLC state (called after each tick).
///
///
///
/// This operation should be atomic and idempotent. Implementations may use
/// fire-and-forget semantics with error logging for performance.
///
///
/// The timestamp state to persist.
/// Cancellation token.
/// A task representing the async operation.
Task SaveAsync(HlcTimestamp timestamp, CancellationToken ct = default);
}