=== Server load balancing

You can configure the pool with a list of servers instead of a single server.

[source,java]
----
Pool pool = PgBuilder.pool()
  .with(options)
  .connectingTo(Arrays.asList(server1, server2, server3))
  .using(vertx)
  .build();
----

The pool uses a round-robin load balancing when a connection is created to select different servers.

NOTE: this provides load balancing when the connection is created and not when the connection is borrowed from the pool.

=== Pool connection initialization

You can use the `link:../../apidocs/io/vertx/sqlclient/ClientBuilder.html#withConnectHandler-io.vertx.core.Handler-[withConnectHandler]` to interact with a connection after it
has been created and before it is inserted in a pool.

[source,java]
----
builder.withConnectHandler(conn -> {
  conn.query(sql).execute().onSuccess(res -> {
    // Release the connection to the pool, ready to be used by the application
    conn.close();
  });
});
----

Once you are done with the connection, you should simply close it to signal the pool to use it.

=== Dynamic connection configuration

You can configure the pool connection details using a Java supplier instead of an instance of `SqlConnectOptions`.

Since the supplier is asynchronous, it can be used to provide dynamic pool configuration (e.g. password rotation).

[source,java]
----
Pool pool = PgBuilder.pool()
  .with(poolOptions)
  .connectingTo(() -> {
    Future<SqlConnectOptions> connectOptions = retrieveOptions();
    return connectOptions;
  })
  .using(vertx)
  .build();
----