Start line:  
End line:  

Snippet Preview

Snippet HTML Code

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

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

Author(s):
Guido Steinacker
Since:
15.04.15
final class HttpCommand<T> extends HystrixCommand<T> {
    private static final Logger LOG = LoggerFactory.getLogger(HttpCommand.class);
    private final Optional<Supplier<T>> fallback;
    private final Function<Response, T> mapper;
    private final int timeout;
    private final TimeUnit timeUnit;
    HttpCommand(final Setter setter,
                final AsyncHttpClient.BoundRequestBuilder requestBuilder,
                final Optional<Supplier<T>> fallback,
                final Function<Response, T> mapper,
                final int timeout,
                final TimeUnit timeUnit) {
        super(requireNonNull(setter));
        this. = requireNonNull(requestBuilder);
        this. = requireNonNull(fallback);
        this. = requireNonNull(mapper);
        this. = timeout;
        this. = requireNonNull(timeUnit);
    }
    @Override
        try {
            return .apply(
                    .execute().get()
            );
        } catch (final Exception e) {
            .error(e.getMessage(), e);
            throw e;
        }
    }
    @Override
    protected T getFallback() {
        return .orElse(() -> super.getFallback()).get();
    }
New to GrepCode? Check out our FAQ X