waitHealthy method
Waits for this container's health check to report healthy.
Returns false if it reports unhealthy, has no health check, or
timeout (default: 1 minute) passes.
Implementation
Future<bool> waitHealthy(
{Duration? timeout,
Duration interval = const Duration(milliseconds: 250)}) async {
var deadline = DateTime.now().add(timeout ?? Duration(minutes: 1));
while (true) {
var status = await healthStatus();
if (status == 'healthy') return true;
if (status == null || status == 'unhealthy') return false;
if (DateTime.now().isAfter(deadline)) return false;
await Future.delayed(interval);
}
}