While playing with it i noticed that i can just use ConnectionPool#pool(...)
So i will convert my question / PR to something else. Do you mind adding futures to the pool classes?
e.g. adding the following methods to ConnectionPool:
/**
* Same as {@link #acquire(EventLoopContext, int, Handler)} )} but returns a future
*/
default Future<Lease<C>> acquire(EventLoopContext context, int kind) {
return Future.future(promise -> {
acquire(context, kind, asyncResult -> {
if (asyncResult.succeeded()) {
promise.complete(asyncResult.result());
} else {
promise.fail(asyncResult.cause());
}
});
});
}
/**
* Same as {@link #acquire(EventLoopContext, PoolWaiter.Listener, int, Handler)} )} but returns a future
*/
default Future<Lease<C>> acquire(EventLoopContext context, PoolWaiter.Listener<C> listener, int kind) {
return Future.future(promise -> {
acquire(context, listener, kind, asyncResult -> {
if (asyncResult.succeeded()) {
promise.complete(asyncResult.result());
} else {
promise.fail(asyncResult.cause());
}
});
});
}