ControlledTransport class final

Wraps a transport with switchable offline, slow and fail-next conditions.

Implemented types

Constructors

ControlledTransport(Transport inner, {Sleep sleep = realSleep, Duration slow = const Duration(milliseconds: 400)})
Wraps inner. sleep is injected so tests do not wait.

Properties

armed → bool
Whether a synthetic failure is waiting to be spent.
no setter
armedStatus → int?
The status the next request will fail with, when armed.
no setter
hashCode → int
The hash code for this object.
no setterinherited
inner → Transport
The transport requests go to when allowed.
final
isOnline → bool
Whether the simulated network is up. Slow counts as up.
no setter
latency ↔ Duration
Extra delay before every request. Not cleared by a principal change.
getter/setter pair
mode ↔ NetworkMode
The current mode.
getter/setter pair
online → Stream<bool>
Emits true when the network comes back and false when it goes.
no setteroverride
released → bool
Whether release was called: the transport passes through for good. The service host attaches no rail for released controls, since every switch on it would be a switch that does nothing.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

disarm() → void
Gives up on the armed failure without spending it. Devtools calls this when the principal starts changing.
dispose() → Future<void>
Closes the connectivity stream, so nothing listening to it is held. Devtools.dispose calls this after release: the release has already reported the network back, and a released transport reports nothing again.
execute(TransportRequest request) → Future<Object?>
Runs request. Returns the client-shaped response.
override
failNext([int status = 500]) → void
Fails the next request, once, with status.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
principalChanged() → void
Tells the transport the principal is changing. Disarms the armed failure and aborts every request still waiting out simulated latency, so none is sent afterwards. The mode and the latency stay. Devtools calls this synchronously from the principal-changing notification.
release() → void
Stops simulating for good: disarms, releases every request waiting out latency straight to inner (the principal is unchanged, so it is still the user's request), and passes through from now on, with no delay and no simulated offline. A request that began before a principalChanged is not released: it is aborted as the change already decided. If the mode was offline, online reports the network back, synchronously, so a held write can drain. Devtools calls this on dispose.
toJson() → Json
The state the panel shows.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited