import { type LeaseToken, type StorageProvider } from '../storage/types.js'; /** * Wrap `provider.acquireLease(...)` with a timeout guard. * * Motivated by observed `Producer.start()` lease re-acquisitions on a * freshly-closed `current-N.jsonl` hanging for tens of minutes on * long-tail Azure responses. Without an outer guard the broker has no * clean "give up" point. * * The guard is a `Promise.race` against a `setTimeout`. When the timer wins, * the helper rejects with {@link LeaseAcquisitionTimeoutError} and the * underlying SDK request may still be in flight on the substrate. That's * acceptable: either the lease was acquired (Azure-side) and will expire after * its TTL, or it wasn't. Either way the orchestrator restarts the process and * the next attempt either sees `LeaseAlreadyHeldError` (caller decides to * wait or exit) or acquires cleanly. * * `timeoutMs` of `0` or negative disables the guard — the underlying call's * own timeouts (Azure SDK's `tryTimeoutInMs`, `maxRetryDelayInMs`) are then * the only bound. */ export declare function acquireLeaseWithTimeout(storage: StorageProvider, path: string, ttlSeconds: number, timeoutMs: number): Promise; /** * Acquire a lease with timeout AND retry-with-jitter on `LeaseAlreadyHeldError`. * * Motivated by restart-storm scenarios: when a previous producer for the * same topic is being killed and a replacement tries `Producer.start` * within seconds, the previous owner's lease may still be in the process * of being released. A single attempt fails with * `LeaseAlreadyHeldError`; a bounded retry-with-jitter lets the previous * lease finish releasing (or its TTL expire) without the caller needing * its own retry loop. * * **Retry budget is bounded.** If after `retryBudgetMs` the lease is still * held, `LeaseAlreadyHeldError` propagates — indicating a real peer is * actively producing for this topic (a configuration error per ADR-0007: * single producer per topic). The orchestrator decides what to do. * * **Each attempt is independently bounded by `timeoutMs`** (the same way * `acquireLeaseWithTimeout` works). The total wall time can therefore * exceed `retryBudgetMs` if individual attempts time out — but each * timeout produces a `LeaseAcquisitionTimeoutError` and stops retrying. * * Jitter is uniform in [0.5×, 1.5×] of the next planned delay, to avoid * synchronised retry storms when multiple Producer.start calls hit * LeaseAlreadyHeld simultaneously. */ export declare function acquireLeaseWithRetry(storage: StorageProvider, path: string, ttlSeconds: number, options: { timeoutMs: number; /** Total wall-clock budget for retries. Default 10 000 ms. Set 0 to disable retries. */ retryBudgetMs?: number; /** Initial backoff between attempts; doubles each attempt up to `maxRetryDelayMs`. Default 200 ms. */ initialRetryDelayMs?: number; /** Cap on per-retry backoff. Default 2 000 ms. */ maxRetryDelayMs?: number; }): Promise; //# sourceMappingURL=leaseTimeout.d.ts.map