Skip to content

Conversation

@vietj
Copy link
Member

@vietj vietj commented Sep 20, 2023

Goals

  • current design with static methods has limited extensibility
    • SqlConnectOptions do not extend anymore NetClientOptions and user should be able to configure it which would clutter the current static methods
  • go away from Pool sub types as they don't declare any methods

Deprecations

For removal in a subsequent PR

  • deprecates Pool subclasses, e.g PgPool
  • deprecate Pool#connectHandler and Pool#connectionProvider

Proposal

A builder class takes an driver instance and build the client according to its state.

Pool pool;

// Build pool with default settings
pool = PgBuilder.pool().using(vertx).build();

// With specific pool settings
pool = PgBuilder
   .pool()
   .connectingTo(new PgConnectOptions().setHost(host).setUsername(username).setPassword(password))
   .using(vertx)
   .build();

// With specific pool settings
pool = PgBuilder
   .pool()
   .with(new PoolOptions().setMaxSize(5))
   .using(vertx)
   .build();

// We should also be able to build pipelined clients when the database supports it
SqlClient client = PgBuilder
   .client()
   .connectingTo(new PgConnectOptions().setHost(host).setUsername(username).setPassword(password))
   .using(vertx)
   .build();

An alternative pattern for the builder API is also provided:

Pool pool = PgBuilder
   .pool(builder -> builder.
      .connectingTo(new PgConnectOptions().setHost(host).setUsername(username).setPassword(password))
      .using(vertx));

@vietj vietj added this to the 5.0.0 milestone Sep 20, 2023
@vietj vietj force-pushed the client-builder branch 19 times, most recently from f844aa8 to ada7bda Compare September 22, 2023 22:31
@vietj vietj marked this pull request as ready for review September 22, 2023 22:46
@vietj vietj merged commit ec87392 into master Sep 23, 2023
@vietj vietj deleted the client-builder branch September 23, 2023 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants