use of io.vertx.reactivex.pgclient.PgPool in project vertx-sandbox by hantsy.
the class MainVerticle method pgPool.
private PgPool pgPool() {
PgConnectOptions connectOptions = new PgConnectOptions().setPort(5432).setHost("localhost").setDatabase("blogdb").setUser("user").setPassword("password");
// Pool Options
PoolOptions poolOptions = new PoolOptions().setMaxSize(5);
// Create the pool from the data object
PgPool pool = PgPool.pool(vertx, connectOptions, poolOptions);
return pool;
}
use of io.vertx.reactivex.pgclient.PgPool in project mod-source-record-storage by folio-org.
the class PostgresClientFactory method getCachedPool.
private static PgPool getCachedPool(Vertx vertx, String tenantId) {
// assumes a single thread Vert.x model so no synchronized needed
if (POOL_CACHE.containsKey(tenantId)) {
LOG.debug("Using existing database connection pool for tenant {}", tenantId);
return POOL_CACHE.get(tenantId);
}
Integer maxPoolSize = postgresConfig.getInteger(DB_MAXPOOLSIZE, DB_MAXPOOLSIZE_DEFAULT_VALUE);
LOG.info("Creating new database connection for tenant {} with poolSize {}", tenantId, maxPoolSize);
PgConnectOptions connectOptions = getConnectOptions(tenantId);
PoolOptions poolOptions = new PoolOptions().setMaxSize(maxPoolSize);
PgPool client = PgPool.pool(vertx, connectOptions, poolOptions);
POOL_CACHE.put(tenantId, client);
return client;
}
Aggregations