execute<T> method

Future<T> execute<T>(
  1. Future<T> operation()
)

Implementation

Future<T> execute<T>(Future<T> Function() operation) async {
  if (_shouldReject()) {
    throw Exception('Circuit breaker $name is open');
  }

  try {
    final result = await operation();
    _onSuccess();
    return result;
  } catch (e) {
    _onFailure();
    rethrow;
  }
}