new RangeGate(optionsopt)
Optional resilience gate for tile reads: concurrency cap + per-attempt TTFB
timeout with smart-abort semantics + retries with backoff. When inactive
(`setActive(false)` or `?nogate`) it is a pure pass-through (raw fetch).
Read live per request, so toggling takes effect without a reload.
Parameters:
| Name | Type | Attributes | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
<optional> |
Properties
|
- Since:
- 2.0.0
- Source:
Methods
isActive()
run(attemptFn, callerSignalopt) → {Promise}
Run one tile-read attempt through the gate. `attemptFn(signal, headersReceived)`
must perform the whole read (fetch + body) and resolve/reject.
SMART ABORT: `signal` is the gate's PRIVATE per-attempt `AbortController`
signal — the TTFB timer and a caller (pan/zoom) cancel abort it ONLY until
the attempt calls `headersReceived()` (do so the moment the response headers
are in). From that point the socket is protected: the body drains to
completion under the generous `bodyTimeoutMs` safety cap, and a caller
cancel is honoured LOGICALLY once the attempt settles (reject `AbortError`,
discard the result — bytes already warmed the browser cache). An `attemptFn`
that never calls `headersReceived` keeps the legacy whole-attempt timeout.
Retries (up to `maxRetries`, spaced by `retryBackoffMs`) apply to transient
failures only — 429/5xx, a network `TypeError`, a timeout `AbortError` —
and NEVER to a caller cancel. Each attempt takes its own concurrency slot
(a retry re-queues at the back instead of squatting a permit across its
backoff sleep).
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
attemptFn |
function | `function(signal, headersReceived) => Promise` | |
callerSignal |
AbortSignal |
<optional> |
the pmtiles cancellation signal |
Returns:
- Type
- Promise
setActive()
Toggle the gate live (no reload). Notifies subscribers. @public
subscribe()
Subscribe to active-state changes. @public @return {Function} unsubscribe