PollingOptions
in package
Tuning knobs for `Dispatcher::startPolling` — port of the constructor parameters of `aiogram.dispatcher.dispatcher.Dispatcher.start_polling` grouped into a single value object.
Why a DTO instead of mirroring upstream's positional kwargs:
start_pollingupstream takes 4+ tunables (timeout, backoff config, allowed_updates, handle_as_tasks, plus concurrency limit). Passing them individually leaks the entry-point signature; bundling them lets callers build a config once and reuse it acrossrunPollingandstartPolling.- The
readonlymodifier means the polling loop never reads a moving target — a config swap requires building a newPollingOptionsand restarting the loop.
Defaults (spec § "Polling loop"):
pollingTimeout=10— long-poll seconds passed togetUpdates. UpstreamDispatcher.start_pollingdefaults to 10 (the internal_pollinghelper defaults to 30, but the public entry point is 10, which is what users see).backoffConfig=new BackoffConfig()— matches upstreamDEFAULT_BACKOFF_CONFIG = BackoffConfig(1.0, 5.0, 1.3, 0.1).allowedUpdates=Unspecified::instance()— Fix I8 sentinel for "auto-resolve viaRouter::resolveUsedUpdateTypes()at polling start" (mirrors upstream'sUNSETdefault atdispatcher.py:526). Distinct fromnull, which remains the explicit "send no allowed_updates key" passthrough so Telegram returns every subscribed type.handleAsTasks=100— concurrent in-flight updates per bot. Upstream exposeshandle_as_tasks: bool(on/off) PLUStasks_concurrency_limit: int|None(cap). Collapsing into oneint|nullslot is denser without losing information:null=> fully serial (handle_as_tasks=False);int n=> concurrent with semaphore of size n (handle_as_tasks=True, tasks_concurrency_limit=n).
Table of Contents
Properties
- $allowedUpdates : null|array<int, string>|Unspecified
- Telegram `allowed_updates` parameter, plus the `Unspecified` sentinel for "auto-resolve at polling start". Three legal shapes:
- $backoffConfig : BackoffConfig
- $handleAsTasks : int|null
- $pollingTimeout : int
Methods
- __construct() : mixed
Properties
$allowedUpdates
Telegram `allowed_updates` parameter, plus the `Unspecified` sentinel for "auto-resolve at polling start". Three legal shapes:
public
null|array<int, string>|Unspecified
$allowedUpdates
Unspecified::instance()(default):Dispatcher::startPollingcallsRouter::resolveUsedUpdateTypes()and substitutes the resultinglist<string>before kicking off the per-bot polling fibers. Mirrors upstreamdispatcher.py:564-565.null: explicit opt-out — thegetUpdatesrequest omits theallowed_updateskey, so Telegram returns every subscribed type.list<string>: a caller-curated list; passed through verbatim.
$backoffConfig
public
BackoffConfig
$backoffConfig
$handleAsTasks
public
int|null
$handleAsTasks
= 100
$pollingTimeout
public
int
$pollingTimeout
= 10
Methods
__construct()
public
__construct([int $pollingTimeout = 10 ][, BackoffConfig|null $backoffConfig = null ][, null|array<int, string>|Unspecified $allowedUpdates = new Unspecified() ][, int|null $handleAsTasks = 100 ]) : mixed
Parameters
- $pollingTimeout : int = 10
-
Long-poll seconds for
getUpdates. 0 means short-poll (return immediately). Must be>= 0. - $backoffConfig : BackoffConfig|null = null
-
Retry tuning;
null=> usenew BackoffConfig()(upstreamDEFAULT_BACKOFF_CONFIG). - $allowedUpdates : null|array<int, string>|Unspecified = new Unspecified()
-
Telegram
allowed_updatesparameter. See$allowedUpdatesproperty docblock for the three legal shapes. Omit the argument to get theUnspecifiedauto-resolve default (PHP can't use a function call as a default value, so the constructor maps a no-arg call to the sentinel in the body). - $handleAsTasks : int|null = 100
-
Concurrent in-flight updates per bot.
null=> fully serial (no fiber spawn); positive int => fiber pool of that size. Must be>= 1ornull.