Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package de.otto.edison.hystrix.http;
 
 
import static java.util.Objects.requireNonNull;
import static java.util.concurrent.CompletableFuture.completedFuture;

A Hystrix command that is asynchronously getting a resource using AsyncHttpClient.

Author(s):
Guido Steinacker
Since:
15.04.15
final class AsyncHttpCommand<T> extends HystrixCommand<Future<T>> {
    private final AsyncHandler<Future<T>> asyncHandler;
    private final int timeout;
    private final TimeUnit timeUnit;
    private final Optional<Supplier<T>> fallback;
    AsyncHttpCommand(final Setter setter,
                     final AsyncHandler<Future<T>> asyncHandler,
                     final AsyncHttpClient.BoundRequestBuilder requestBuilder,
                     final Optional<Supplier<T>> fallback,
                     final int timeout,
                     final TimeUnit timeUnit) {
        super(requireNonNull(setter));
        this. = requireNonNull(requestBuilder);
        this. = requireNonNull(asyncHandler);
        this. = requireNonNull(fallback);
        this. = timeout;
        this. = requireNonNull(timeUnit);
    }
    @Override
    }
    @Override
    protected Future<T> getFallback() {
        if (.isPresent()) {
            return completedFuture(.get().get());
        } else {
            return super.getFallback();
        }
    }
New to GrepCode? Check out our FAQ X