poll method
Calls check every interval until it returns true.
Throws a ContainerLaunchException when the container exited in the
meantime, or when description did not come true within remaining.
Implementation
@override
Future<void> poll(
String description,
Future<bool> Function() check, {
Duration interval = const Duration(milliseconds: 100),
}) async {
while (true) {
final state = await inspect();
if (!state.running) {
throw ContainerLaunchException(
'The container of $image stopped (${state.status}, exit code '
'${state.exitCode}) before $description',
);
}
if (await check()) {
return;
}
if (remaining <= Duration.zero) {
throw ContainerLaunchException(
'The container of $image was not ready after '
'${_timeout.inSeconds} s: waiting for $description',
);
}
await Future<void>.delayed(interval);
}
}