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

Add example on how to pass a custom configuration for the Vert.x client #1866

Open
DavideD opened this issue Feb 22, 2024 · 0 comments
Open
Labels

Comments

@DavideD
Copy link
Member

DavideD commented Feb 22, 2024

We need to document with an example how it's possible to add a custom configuration for the Vert.x SQL client.
For example:

public class PgClientPoolConfiguration extends DefaultSqlClientPoolConfiguration {

    private static String HIBERNATE_VERTX_PGSQL_SSL = "hibernate.vertx.pgsql.ssl";
    private static String HIBERNATE_VERTX_PGSQL_SSL_MODE = "hibernate.vertx.pgsql.ssl.mode";

    private boolean ssl;
    private String sslMode;

    @Override
    public void configure(Map configuration) {
        super.configure(configuration);
        ssl = ConfigurationHelper.getBoolean(HIBERNATE_VERTX_PGSQL_SSL, configuration);
        sslMode = ConfigurationHelper.getString(HIBERNATE_VERTX_PGSQL_SSL_MODE, configuration);
    }

    @Override
    public SqlConnectOptions connectOptions(URI uri) {
        SqlConnectOptions sqlConnectOptions = super.connectOptions(uri);
        PgConnectOptions pgConnectOptions = new PgConnectOptions(sqlConnectOptions);

        if (ssl) {
            pgConnectOptions.setSsl(true);
            pgConnectOptions.setTrustAll(true);
            pgConnectOptions.setSslMode(SslMode.of(sslMode));
        }
        return pgConnectOptions;
    }
}

Related to this: #1108 (comment)

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

No branches or pull requests

1 participant