Files
KArtSell.Aegis/docs/Design/kbx-foundation-v60-status-canonical-contract-hardening/backend/Shared/Providers/KisRequestPacer.cs
T
kjh2064 3f293d8aa8
deploy / deploy (push) Successful in 1m52s
deploy / notify (push) Successful in 1s
V13-FE-006: consolidate approved UI and contract hardening
2026-08-13 02:41:00 +09:00

20 lines
704 B
C#

namespace Kbx.Shared.Providers;
public sealed class KisRequestPacer
{
private readonly SemaphoreSlim _gate = new(1,1);
private DateTimeOffset _last = DateTimeOffset.MinValue;
public async ValueTask WaitAsync(bool sandbox, CancellationToken ct)
{
await _gate.WaitAsync(ct);
try
{
var spacing = TimeSpan.FromMilliseconds(sandbox ? 1000 : 100); // KBX conservative default; official production max is higher.
var remaining = spacing - (DateTimeOffset.UtcNow - _last);
if (remaining > TimeSpan.Zero) await Task.Delay(remaining, ct);
_last = DateTimeOffset.UtcNow;
}
finally { _gate.Release(); }
}
}