-
public interface AsyncSupport 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 classAsync.BuilderFluent API Builder forAsync.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static Async.Builderbuilder()A new builder to build a customizedAsyncinstance.static Asynccreate()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 theSingleresult.- 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 customizedAsyncinstance.- Returns:
- a new builder
-
-