|
24 | 24 |
|
25 | 25 | import java.text.ParseException; |
26 | 26 |
|
| 27 | +import io.vertx.pgclient.PgConnectOptions; |
| 28 | +import io.vertx.pgclient.PgPool; |
| 29 | +import io.vertx.pgclient.SslMode; |
| 30 | +import io.vertx.sqlclient.PoolOptions; |
27 | 31 | import org.entcore.common.aggregation.MongoConstants.COLLECTIONS; |
28 | 32 | import org.entcore.common.events.EventHelper; |
29 | 33 | import org.entcore.common.events.EventStore; |
30 | 34 | import org.entcore.common.events.EventStoreFactory; |
31 | 35 | import org.entcore.common.http.BaseServer; |
32 | 36 | import org.entcore.common.mongodb.MongoDbConf; |
33 | 37 |
|
34 | | -import io.reactiverse.pgclient.PgClient; |
35 | | -import io.reactiverse.pgclient.PgPool; |
36 | | -import io.reactiverse.pgclient.PgPoolOptions; |
37 | 38 | import io.vertx.core.json.JsonObject; |
38 | 39 | import io.vertx.core.logging.Logger; |
39 | 40 | import io.vertx.core.logging.LoggerFactory; |
@@ -85,23 +86,31 @@ public void start() throws Exception { |
85 | 86 | final JsonObject readPGConfig = config.getJsonObject("read-pg-config"); |
86 | 87 | final boolean oldStats = config.getBoolean("mongo-stats-service", false); |
87 | 88 | if (readPGConfig != null && !readPGConfig.isEmpty() && !oldStats) { |
88 | | - final PgPoolOptions options = new PgPoolOptions().setPort(readPGConfig.getInteger("port", 5432)) |
| 89 | + final PgConnectOptions connectOptions = new PgConnectOptions().setPort(readPGConfig.getInteger("port", 5432)) |
89 | 90 | .setHost(readPGConfig.getString("host")).setDatabase(readPGConfig.getString("database")) |
90 | | - .setUser(readPGConfig.getString("user")).setPassword(readPGConfig.getString("password")) |
91 | | - .setMaxSize(readPGConfig.getInteger("pool-size", 5)); |
92 | | - PgPool pgPool = PgClient.pool(vertx, options); |
| 91 | + .setUser(readPGConfig.getString("user")).setPassword(readPGConfig.getString("password")); |
| 92 | + final SslMode sslMode = SslMode.valueOf(readPGConfig.getString("ssl-mode", "DISABLE")); |
| 93 | + if (!SslMode.DISABLE.equals(sslMode)) { |
| 94 | + connectOptions.setSslMode(sslMode).setTrustAll(SslMode.ALLOW.equals(sslMode) || SslMode.PREFER.equals(sslMode) || SslMode.REQUIRE.equals(sslMode)); |
| 95 | + } |
| 96 | + PoolOptions poolOptions = new PoolOptions().setMaxSize(readPGConfig.getInteger("pool-size", 5)); |
| 97 | + PgPool pgPool = PgPool.pool(vertx, connectOptions, poolOptions); |
93 | 98 | statsService = new PGStatsService(platformId, config.getJsonObject("api-allowed-values")); |
94 | 99 | ((PGStatsService) statsService).setReadPgPool(pgPool); |
95 | 100 | } else if (eventStoreConfig != null && eventStoreConfig.getJsonObject("postgresql-slave") != null && !oldStats) { |
96 | 101 | final JsonObject eventStorePGConfig = eventStoreConfig.getJsonObject("postgresql-slave"); |
97 | | - final PgPoolOptions options = new PgPoolOptions() |
| 102 | + final PgConnectOptions connectOptions = new PgConnectOptions() |
98 | 103 | .setPort(eventStorePGConfig.getInteger("port", 5432)) |
99 | 104 | .setHost(eventStorePGConfig.getString("host")) |
100 | 105 | .setDatabase(eventStorePGConfig.getString("database")) |
101 | 106 | .setUser(eventStorePGConfig.getString("user")) |
102 | | - .setPassword(eventStorePGConfig.getString("password")) |
103 | | - .setMaxSize(eventStorePGConfig.getInteger("pool-size", 5)); |
104 | | - PgPool pgPool = PgClient.pool(vertx, options); |
| 107 | + .setPassword(eventStorePGConfig.getString("password")); |
| 108 | + final SslMode sslMode = SslMode.valueOf(eventStorePGConfig.getString("ssl-mode", "DISABLE")); |
| 109 | + if (!SslMode.DISABLE.equals(sslMode)) { |
| 110 | + connectOptions.setSslMode(sslMode).setTrustAll(SslMode.ALLOW.equals(sslMode) || SslMode.PREFER.equals(sslMode) || SslMode.REQUIRE.equals(sslMode)); |
| 111 | + } |
| 112 | + PoolOptions poolOptions = new PoolOptions().setMaxSize(eventStorePGConfig.getInteger("pool-size", 5)); |
| 113 | + PgPool pgPool = PgPool.pool(vertx, connectOptions, poolOptions); |
105 | 114 | statsService = new PGStatsService(platformId, config.getJsonObject("api-allowed-values")); |
106 | 115 | ((PGStatsService) statsService).setReadPgPool(pgPool); |
107 | 116 | } else { |
|
0 commit comments