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

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

The newest version!
package org.zalando.riptide;

import lombok.AllArgsConstructor;

import java.util.concurrent.Executor;

import static java.util.concurrent.CompletableFuture.supplyAsync;
import static java.util.function.Function.identity;
import static org.zalando.fauxpas.FauxPas.throwingSupplier;

@AllArgsConstructor
final class AsyncPlugin implements Plugin {

    private final Executor executor;

    @Override
    public RequestExecution aroundAsync(final RequestExecution execution) {
        return arguments ->
                supplyAsync(throwingSupplier(() -> execution.execute(arguments)), executor)
                .thenCompose(identity());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy