ServeOptions class final
Options for Application.serve.
Constructors
- ServeOptions({String host = '127.0.0.1', int port = 8000, int isolates = 1, Duration idleTimeout = const Duration(seconds: 60), Duration shutdownTimeout = const Duration(seconds: 30), Duration? requestTimeout = const Duration(seconds: 30), bool handleSignals = true, Duration readyTimeout = const Duration(seconds: 30), bool embedQueue = false, bool embedScheduler = false, int? maxInFlight, Duration? maxQueueDelay, int? maxBodyBytes = defaultMaxBodyBytes})
-
const
- ServeOptions.fromEnv(Env env, {String? host, int? port, int? isolates, bool? embedQueue, bool? embedScheduler, int? maxInFlight, Duration? maxQueueDelay})
-
Reads
APP_HOST/APP_PORT, overridable by explicit arguments.factory
Properties
- embedQueue → bool
-
Runs a queue worker in its own isolate next to the HTTP workers
(
serve --embed-queue,SERVER_EMBED_QUEUE).final - embedScheduler → bool
-
Runs the scheduler in its own isolate, so no cron entry is needed
(
serve --embed-scheduler,SERVER_EMBED_SCHEDULER).final - handleSignals → bool
-
Whether this engine installs SIGINT/SIGTERM handlers (workers under a
supervisor leave signals to the supervisor).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- host → String
-
final
- idleTimeout → Duration
-
How long a keep-alive connection may sit without a request before
the server closes it (
HTTP_IDLE_TIMEOUT, 60 s): the bound on idle sockets a client opens and never uses. A request in progress is bounded by requestTimeout instead.final - isolates → int
-
Number of HTTP worker isolates (
APP_ISOLATES,serve --isolates). Above 1,Application.serveWithruns a supervisor + workers (ADR-004).final - maxBodyBytes → int?
-
The body limit every request starts with (
HTTP_MAX_BODY, 50 MiB): a declaredContent-Lengthabove it is refused with413before the body is read, and a body that grows past it while read is cut off.BodyLimitsMiddlewareandRouteEntry.bodyLimitreplace it per content type or route; without them an application still never buffers an unbounded body in memory.null(HTTP_MAX_BODY=0) sets no limit.final - maxInFlight → int?
-
Load shedding (
HTTP_MAX_IN_FLIGHT,serve --max-in-flight): the most requests one worker isolate handles at once. Beyond it a request is refused at once with503 Service UnavailableandRetry-After: 1, before routing, middleware or a request scope run, so an overloaded worker fails fast instead of queueing until every client times out. The health probes are never refused.null(the default) sets no limit. Under a supervisor the limit is per worker, so the server takes up toAPP_ISOLATES × HTTP_MAX_IN_FLIGHTrequests at once.final - maxQueueDelay → Duration?
-
Load shedding by event-loop lag (
HTTP_MAX_QUEUE_DELAY,serve --max-queue-delay): a timer measures how late the worker's event loop runs it, which is how long a request has been waiting in the socket and event queues before the engine even sees it. Above this delay requests are refused with503like maxInFlight. This is the limit that catches synchronous work: a handler that only touches SQLite or the CPU finishes within one event-loop turn, so it never counts as in flight, and the queue in front of it is invisible to maxInFlight.null(the default) turns it off.final - port → int
-
final
- readyTimeout → Duration
-
How long the supervisor waits for every worker to bind.
final
- requestTimeout → Duration?
-
Default handler timeout (routes may override with
RouteEntry.timeout);nulldisables it.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
final
- shutdownTimeout → Duration
-
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- defaultMaxBodyBytes → const int
-
The body limit a request starts with: Request.defaultMaxBodyBytes
(50 MiB, the widest limit
BodyLimitsMiddlewareapplies).