Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking change #1324

Open
hogmuzzle opened this issue May 23, 2023 · 4 comments
Open

Breaking change #1324

hogmuzzle opened this issue May 23, 2023 · 4 comments
Assignees

Comments

@hogmuzzle
Copy link

In version 4.2.4 io.vertx.sqlclient.impl.PoolBase had accessible field closeFuture and it was possible to correctly create custom connectionProvider and add ConnectionFactory to close future.
List lst = pgConnectOptions.stream()
.map(options -> driver.createConnectionFactory(vertx.getDelegate(), options))
.collect(Collectors.toList());
ConnectionFactory factory = serverSelector(lst);
pool.getDelegate().connectionProvider(factory::connect);
PgPoolImpl poolBase = (PgPoolImpl) pool.getDelegate();
CloseFuture closeFuture = poolBase.closeFuture();
closeFuture.add(factory);
It is no longer possible.
Could you please add information to your documentation as to how to create a connection provider. This information used to be in your documentation but it not there any more or complement ConnectionFactory with one more implementation of ConnectionFactory.

static ConnectionFactory failOverSelector(final List factories) {
return factories.size() == 1 ? (ConnectionFactory)factories.get(0) : new ConnectionFactory() {
int idx = 0;

        public Future<SqlConnection> connect(Context context) {
            ConnectionFactory f = (ConnectionFactory)factories.get(this.idx);
            return f.connect(context).onFailure(th -> {						
	  idx = (idx + 1) % factories.size();
	});
        }

        public void close(Promise<Void> promise) {
            List<Future> list = new ArrayList(factories.size());
            Iterator var3 = factories.iterator();

            while(var3.hasNext()) {
                ConnectionFactory factory = (ConnectionFactory)var3.next();
                Promise<Void> p = Promise.promise();
                factory.close(p);
                list.add(p.future());
            }

            CompositeFuture.all(list).mapEmpty().onComplete(promise);
        }
    };
}

We use PostgreSQL HA with Patroni and roundRobinSelector is of no use. I have never seen a configuration where roundRobinSelector was used.

@tsegismont
Copy link
Contributor

@hogmuzzle the API changed after #1305

There is an example of the new API here: https://vertx.io/docs/vertx-pg-client/java/#_dynamic_connection_configuration

You no longer need access to the CloseFuture because the lifecyle is handled internally.

@vietj can you please update the https://github.com/vert-x3/wiki/wiki/4.4.2-Deprecations-and-breaking-changes ?

@vietj
Copy link
Member

vietj commented Jun 12, 2023

that's an internal change, not sure we need to document that

@vietj
Copy link
Member

vietj commented Jun 12, 2023

@hogmuzzle can you elaborate about exactly what you want to achieve ? it is not clear to me (also the fact you had to use internal stuff from vertx)

@tsegismont
Copy link
Contributor

that's an internal change, not sure we need to document that

Right. I thought we had removed the io.vertx.sqlclient.Pool#connectionProvider method but we haven't.
Sorry for the confusion.

@hogmuzzle can you elaborate about exactly what you want to achieve ? it is not clear to me (also the fact you had to use internal stuff from vertx)

I believe they want to create new connections depending on which server in the cluster is currently the leader (in a HA scenario).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants