Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static <T> Supplier<T> decorateSupplier(CircuitBreaker circuitBreaker, Supplier<T> supplier){
- return () -> {
- CircuitBreakerUtils.isCallPermitted(circuitBreaker);
- long start = System.nanoTime();
- try {
- T returnValue = supplier.get();
- long durationInNanos = System.nanoTime() - start;
- circuitBreaker.onSuccess(durationInNanos);
- return returnValue;
- } catch (Throwable throwable) {
- long durationInNanos = System.nanoTime() - start;
- circuitBreaker.onError(durationInNanos, throwable);
- throw throwable;
- }
- };
- }
Add Comment
Please, Sign In to add comment