recordError method
void
recordError()
Implementation
void recordError() {
// avoid leak by skipping in unhealthy state
if (_healthy) {
final now = DateTime.now();
final end = _errorTimestamps.lastIndexWhere(
(t) => t.isBefore(now.subtract(Duration(seconds: 5))),
);
if (end > -1) {
_errorTimestamps.removeRange(0, end);
}
_errorTimestamps.add(now);
if (_errorTimestamps.length > 25) {
setUnhealthy();
}
} else {
_errorTimestamps.clear();
}
}