All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.zalando.riptide.AsyncPlugin Maven / Gradle / Ivy

package org.zalando.riptide;

import lombok.AllArgsConstructor;
import org.springframework.http.client.ClientHttpResponse;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

import static org.zalando.fauxpas.FauxPas.throwingRunnable;
import static org.zalando.riptide.CompletableFutures.forwardTo;

@AllArgsConstructor
final class AsyncPlugin implements Plugin {

    private final Executor executor;

    @Override
    public RequestExecution aroundAsync(final RequestExecution execution) {
        return arguments -> {
            final CompletableFuture future = new CompletableFuture<>();

            executor.execute(throwingRunnable(() ->
                    execution.execute(arguments).whenComplete(forwardTo(future))));

            return future;
        };
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy