Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package de.otto.edison.hystrix.http;
 
 
import static com.netflix.hystrix.HystrixCommand.Setter.withGroupKey;
import static java.util.Objects.requireNonNull;
import static java.util.Optional.ofNullable;

A fluent builder used to create and configure http commands.

Author(s):
Guido Steinacker
Since:
16.04.15
public final class AsyncHttpCommandBuilder<T> {
    private AsyncHandler<Future<T>> handler;
    protected HystrixCommand.Setter setter;
    protected Optional<Supplier<T>> optionalFallback = Optional.empty();
    protected int timeout = 10;
    protected TimeUnit timeUnit = .;
    public static AsyncHttpCommandBuilder<ResponseasyncHttpCommand() {
        return new AsyncHttpCommandBuilder<Response>();
    }
    public static <T> AsyncHttpCommandBuilder<T> asyncHttpCommand(final Class<T> type) {
        return new AsyncHttpCommandBuilder<T>();
    }
    public AsyncHttpCommandBuilder<T> inGroup(final HystrixCommandGroupKey group) {
        this. = withGroupKey(group);
        return this;
    }
    public AsyncHttpCommandBuilder<T> configuredBy(final HystrixCommand.Setter setter) {
        this. = setter;
        return this;
    }
    public AsyncHttpCommandBuilder<T> forRequest(final AsyncHttpClient.BoundRequestBuilder requestBuilder) {
        this. = requireNonNull(requestBuilder);
        return this;
    }
    public AsyncHttpCommandBuilder<T> withFallback(final Supplier<T> fallback) {
        this. = ofNullable(fallback);
        return this;
    }
    public AsyncHttpCommandBuilder<T> timingOutAfter(final int timeoutfinal TimeUnit timeUnit) {
        this. = timeout;
        this. = requireNonNull(timeUnit);
        return this;
    }
    public AsyncHttpCommandBuilder<T> handledBy(final AsyncHandler<Future<T>> handler) {
        this. = handler;
        return this;
    }
    public HystrixCommand<Future<T>> build() {
        return new AsyncHttpCommand<>(
                ,
                ,
                ,
                ,
                );
    }
    }
New to GrepCode? Check out our FAQ X