currentEngine function

Future<DockerEngine> currentEngine({
  1. Future<DockerEngine> connect() = connectToDocker,
})

The Docker client for this isolate, connected on first use.

One per isolate rather than one per process, because dart test runs each test file in its own isolate and they share no memory. Sharing containers between them is done through Docker's own labels, not through this.

A failed attempt is deliberately not remembered. Docker may simply have been starting up, or a single ping may have been unlucky; caching the failure would turn one bad moment into every later call in this isolate failing with no retry. connect exists so rig's own tests can exercise that without a daemon.

Implementation

Future<DockerEngine> currentEngine({
  Future<DockerEngine> Function() connect = connectToDocker,
}) => _pending ??= _connectAndForgetOnFailure(connect);