import type { TelegramUpdate } from '@puregram/api'; import type { Telegram } from '../telegram.js'; export interface StartPollingOptions { offset?: number; timeout?: number; dropPendingUpdates?: boolean | string[]; allowedUpdates?: string[] | 'auto'; /** * cap the number of update dispatches that run in parallel. when the cap is * reached, the next update waits for a slot. defaults to `Infinity` * (unbounded — preserves existing behavior) */ concurrency?: number; /** * backpressure — stop pulling new updates while this many dispatches are in * flight (running + queued). fetching resumes as dispatches settle. telegram * holds the unfetched updates server-side until the offset advances again, so * the in-memory queue stays bounded instead of growing without limit under * sustained overload. defaults to `Infinity` (no backpressure — preserves * existing behavior). compose with `concurrency` to bound both the running and * the queued set */ maxInFlight?: number; /** * return a key for a given raw update to serialize dispatch per-key. updates * sharing a key run in FIFO order; updates with different keys still run in * parallel (subject to `concurrency`). `undefined`/empty key opts out * * @example * ```ts * sequentializeBy: (raw) => * String(raw.message?.chat.id ?? raw.callback_query?.message?.chat.id ?? '') * ``` */ sequentializeBy?: (raw: TelegramUpdate) => string | undefined; } export interface PollingDeps { tg: Telegram; buildAndDispatch: (rawUpdate: Record) => Promise; trackInFlight: (p: Promise) => void; onError: (error: Error, rawUpdate: Record) => void; } export declare class PollingTransport { private readonly deps; private offset; private retries; private isStarted; private slots; private slotsInitialized; private readonly waiters; private readonly keyQueues; private inFlight; private readonly capacityWaiters; constructor(deps: PollingDeps); start(options?: StartPollingOptions): Promise; stop(): void; drop(value?: boolean | string[]): Promise; private loop; private tick; private scheduleDispatch; private runDispatch; private acquireSlot; private releaseSlot; private waitForCapacity; private onSettled; } //# sourceMappingURL=polling.d.ts.map