namespace ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories; /// /// Register row 52: read/write access to the central BundleUnlockAttempt table, /// the fleet-wide sliding window behind the Transport component's per-client bundle-unlock /// throttle. Both central nodes share this store, so the documented /// MaxUnlockAttemptsPerIpPerHour cap is a fleet cap rather than a per-process one. /// /// /// The throttle is a best-effort rate cap layered over an already-authenticated, /// role-gated surface. Callers are expected to treat a store failure as fail-open (the /// availability of legitimate imports outranks the cap), so no method here is required to /// be transactional with respect to the caller's own work. /// public interface IBundleUnlockAttemptRepository { /// /// Counts the attempts recorded for at or after /// — the trailing-window depth the cap is compared against. /// /// Throttle bucket (client IP, or the shared unattributed bucket). /// Inclusive UTC lower bound of the trailing window. /// Cancellation token. /// The number of attempts inside the window. Task CountAttemptsSinceAsync(string clientKey, DateTime sinceUtc, CancellationToken ct = default); /// /// Appends one attempt row for . /// /// Throttle bucket (client IP, or the shared unattributed bucket). /// UTC instant of the attempt. /// Cancellation token. /// A task that completes when the row is committed. Task RecordAttemptAsync(string clientKey, DateTime attemptedAtUtc, CancellationToken ct = default); /// /// Deletes attempt rows older than , up to /// in one bounded pass. Bounded so an opportunistic prune on /// a request path can never turn into an unbounded delete. /// /// Exclusive UTC upper bound — rows strictly older than this are eligible. /// Maximum rows to delete in this pass; must be positive. /// Cancellation token. /// The number of rows deleted. Task PruneAttemptsOlderThanAsync(DateTime beforeUtc, int maxRows, CancellationToken ct = default); }