-
public interface Async
Support for asynchronous execution of synchronous (blocking) calls. While this does not miraculously make a synchronous call non-blocking, it at least moves the blocking calls to a separate executor service, degrading the service gracefully.Example of usage:
// async instance with default executor service Async async = Async.create(); // call a method with no parameters Single<String> result = async.invoke(this::slowSync); // call a method with parameters async.invoke(() -> processRequest(request)) .thenApply(response::send); // use async to obtain a Multi (from a method returning List of strings) Multi<String> stringMulti = async.invoke(this::syncList) .flatMap(Multi::create);
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Async.Builder
Fluent API Builder forAsync
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Async.Builder
builder()
A new builder to build a customizedAsync
instance.static Async
create()
Async with default executor service.<T> Single<T>
invoke(Supplier<T> supplier)
Invoke a synchronous operation asynchronously.
-
-
-
Method Detail
-
invoke
<T> Single<T> invoke(Supplier<T> supplier)
Invoke a synchronous operation asynchronously. This method never throws an exception. Any exception is returned via theSingle
result.- Type Parameters:
T
- type of returned value- Parameters:
supplier
- supplier of value (may be a method reference)- Returns:
- a Single that is a "promise" of the future result
-
create
static Async create()
Async with default executor service.- Returns:
- a default async instance
-
builder
static Async.Builder builder()
A new builder to build a customizedAsync
instance.- Returns:
- a new builder
-
-