FakeWorkerTransport class final

A scriptable WorkerTransport for unit-testing pool/protocol logic on the VM: executes tasks from a TaskRegistry in-process while letting the test inject spawn failures, latency, task failures, and crashes — and records everything that was sent.

Implemented types

Constructors

FakeWorkerTransport({TaskRegistry? registry, bool failSpawn = false, Duration? readyDelay, Duration? taskLatency, bool clonePayloads = true})
Creates a fake transport.

Properties

failSpawn bool
When true, ready fails with WorkerSpawnException.
final
hashCode int
The hash code for this object.
no setterinherited
messages Stream<Envelope>
Result/error envelopes coming back. A stream error means the executor itself died (crash, not task failure).
no setteroverride
ready Future<void>
Completes when the executor is accepting tasks; fails with WorkerSpawnException when it never came up.
no setteroverride
readyDelay Duration?
Delay before ready completes.
final
registry TaskRegistry
The registry tasks are dispatched into.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sentEnvelopes List<Envelope>
Every envelope passed to send, in order.
final
sentTransferFlags List<bool>
The transferBuffers flag of each send, parallel to sentEnvelopes.
final
taskLatency Duration?
Delay before each task reply is emitted.
final
terminateCount int
Number of times terminate was called.
getter/setter pair

Methods

crash([Object error = 'FakeWorkerTransport.crash()']) → void
Simulates the worker dying: emits a stream error (not a protocol error envelope), which a pool treats as a crash of the in-flight task.
failNextTask([String message = 'scripted task failure']) → void
Makes the next task fail with an error envelope carrying message (queues up if called repeatedly).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
send(Envelope envelope, {bool transferBuffers = false}) → void
Sends a task envelope. When transferBuffers is true, every ArrayBuffer reachable from the payload is moved (zero-copy) rather than cloned, detaching it on the sending side.
override
terminate() Future<void>
Tears the executor down; safe to call more than once.
override
toString() String
A string representation of this object.
inherited

Operators

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