ServerEngine class final
Binds the dart:io server, wraps every request in a request scope and
performs graceful shutdown on SIGINT (and SIGTERM outside Windows).
Constructors
-
ServerEngine(Application app, ServeOptions options, {required HttpKernel kernel, required Logger logger, FutureOr<
void> prepare(Request request)?, void onShed()?})
Properties
- app → Application
-
final
-
done
→ Future<
void> -
Completes once the server has stopped.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- inFlight → int
-
Requests this engine is handling right now (open WebSockets are not
counted once upgraded; see openWebSockets).
no setter
- kernel → HttpKernel
-
final
- logger → Logger
-
final
- onShed → void Function()?
-
Called for every request refused by load shedding (the application
counts them in
http_requests_shed_total).final - openWebSockets → int
-
Open WebSocket connections on this engine.
no setter
- options → ServeOptions
-
final
- port → int?
-
The bound port (useful when
port: 0was requested).no setter -
prepare
→ FutureOr<
void> Function(Request request)? -
Runs inside each request's scope before the kernel (as
Application.handle'sprepare); the testing toolkit uses it to authenticate socket requests (actingAs).final - queueDelay → Duration
-
The event loop's current lag: how late the last lag tick ran, smoothed
over the last few ticks, or how overdue the next tick already is when
that is more. Zero without ServeOptions.maxQueueDelay.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- shedRequests → int
-
Requests refused with 503 because ServeOptions.maxInFlight or
ServeOptions.maxQueueDelay was reached.
no setter
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
start(
) → Future< void> - Binds and starts listening.
-
stop(
{bool force = false}) → Future< void> - Stops accepting connections, lets in-flight requests finish (up to ServeOptions.shutdownTimeout) and completes done.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Constants
- lagTick → const Duration
- How often the lag timer runs; the measured lag is at least this coarse, so the smallest useful ServeOptions.maxQueueDelay is a few ticks.