New Pool Implementation

126 views
Skip to first unread message

Tom Fingerman

unread,
Jun 8, 2021, 4:00:57 AM6/8/21
to vert.x
Hi,


I was looking for a good non-blocking pool implementation (object pool) in order to use with libraries that does not have a pool implementation (for example to manage a pool of java sockets, pool of connection objects of old libraries / connectors)

It would be really nice if you can open those classes so they can be initialized and used to implement custom object pools. For example SimpleConnectionPool constructor is package protected so it can not be initialized outside of vertx.

Thanks in advance :)

Julien Viet

unread,
Jun 8, 2021, 4:06:11 AM6/8/21
to vert.x
Hi Tom,

we could do that, however we cannot guarantee that the API will remain
stable (i.e it could change over time if we have new needs to
address), although I'm fairly confident it is quite stable now.

do you mind providing a PR for that ?

Julien
> --
> You received this message because you are subscribed to the Google Groups "vert.x" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/3882d68b-e1d8-4e4d-ac64-ee7e87aa288fn%40googlegroups.com.

Tom Fingerman

unread,
Jun 8, 2021, 4:09:51 AM6/8/21
to vert.x
Sure, and i understand its internal and can be changed of course but i hope it will not be removed ;)

I will open a PR.

Tom Fingerman

unread,
Jun 8, 2021, 6:57:30 AM6/8/21
to vert.x
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());
      }
     });
   });
}

Julien Viet

unread,
Jun 8, 2021, 9:11:21 AM6/8/21
to vert.x
we plan to keep it for a while.
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/a8343cf6-0144-4bfe-b988-636eb13cc4f9n%40googlegroups.com.

Julien Viet

unread,
Jun 8, 2021, 9:12:32 AM6/8/21
to vert.x
no we don't plan to do that because it remains low level and should be
wrapped by an actual pool, e.g HttpClient internal pool or Pool in SQL
client
> To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/4ca5e3d9-f60c-443d-98cd-088993b75b04n%40googlegroups.com.

Tom Fingerman

unread,
Jun 8, 2021, 9:29:06 AM6/8/21
to vert.x
ok, thanks for the clarifications
Reply all
Reply to author
Forward
0 new messages