Skip to content

Commit

Permalink
Get rid of usages of PgPool which was deprecated in 4.5
Browse files Browse the repository at this point in the history
  • Loading branch information
ShreckYe committed Nov 15, 2024
1 parent 7b0fc9f commit e959812
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import io.vertx.core.buffer.Buffer
import io.vertx.kotlin.coroutines.coAwait
import io.vertx.kotlin.sqlclient.poolOptionsOf
import io.vertx.pgclient.PgConnectOptions
import io.vertx.pgclient.PgPool
import io.vertx.sqlclient.*
import kotlinx.coroutines.coroutineScope
import org.jetbrains.exposed.dao.id.EntityID
Expand Down Expand Up @@ -473,7 +472,7 @@ fun createPgPoolDatabaseClient(
vertxSqlClientConnectionConfig: ConnectionConfig,
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf(),
exposedDatabase: Database
): DatabaseClient<PgPool> =
): DatabaseClient<Pool> =
DatabaseClient(
with(vertxSqlClientConnectionConfig) {
when (this) {
Expand All @@ -494,7 +493,7 @@ fun createPgPoolDatabaseClient(
vertxSqlClientConnectionConfig: ConnectionConfig,
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf(),
exposedSocketConnectionConfig: Socket
): DatabaseClient<PgPool> =
): DatabaseClient<Pool> =
createPgPoolDatabaseClient(
vertx, vertxSqlClientConnectionConfig, extraPgConnectOptions, poolOptions,
exposedDatabaseConnectPostgreSql(exposedSocketConnectionConfig)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ inline fun <Client, PoolOptionsT : PoolOptions?> createSocketGenericPgClient(
return create(vertx, pgConnectOptions, poolOptions)
}

private const val PG_CLIENT_DEPRECATED_MESSAGE =
"The dependent `PgPool` is deprecated. Just use `Pool` with `pipelined` enabled, which is the difference between `PgPool.client` and `PgPool.pool` as I have found out."

@Deprecated(PG_CLIENT_DEPRECATED_MESSAGE, ReplaceWith("createSocketPgPool"))
fun createSocketPgSqlClient(
vertx: Vertx?,
host: String, port: Int?, database: String, user: String, password: String,
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf()
): SqlClient =
@Suppress("DEPRECATION")
createSocketGenericPgClient<SqlClient, PoolOptions>(
vertx, host, port, database, user, password, extraPgConnectOptions, poolOptions, PgPool::client
)
Expand All @@ -68,9 +73,9 @@ fun createSocketPgPool(
vertx: Vertx?,
host: String, port: Int?, database: String, user: String, password: String,
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf()
): PgPool =
createSocketGenericPgClient<PgPool, PoolOptions>(
vertx, host, port, database, user, password, extraPgConnectOptions, poolOptions, PgPool::pool
): Pool =
createSocketGenericPgClient<Pool, PoolOptions>(
vertx, host, port, database, user, password, extraPgConnectOptions, poolOptions, Pool::pool
)

@Untested
Expand Down Expand Up @@ -103,15 +108,18 @@ inline fun <Client, PoolOptionsT : PoolOptions?> createPeerAuthenticationUnixDom
return create(vertx, pgConnectOptions, poolOptions)
}

@Deprecated(PG_CLIENT_DEPRECATED_MESSAGE, ReplaceWith("createPeerAuthenticationUnixDomainSocketPgPool"))
fun createPeerAuthenticationUnixDomainSocketPgSqlClient(
vertx: Vertx?,
unixDomainSocketPath: String, database: String,
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf()
): SqlClient =
@Suppress("DEPRECATION")
createPeerAuthenticationUnixDomainSocketGenericPgClient<SqlClient, PoolOptions>(
vertx, unixDomainSocketPath, database, extraPgConnectOptions, poolOptions, PgPool::client
)

@Deprecated(PG_CLIENT_DEPRECATED_MESSAGE, ReplaceWith("createPeerAuthenticationUnixDomainSocketPgPoolAndSetRole"))
suspend fun createUnixDomainSocketPgSqlClientAndSetRole(
vertx: Vertx?,
host: String, database: String, role: String,
Expand All @@ -128,16 +136,16 @@ fun createPeerAuthenticationUnixDomainSocketPgPool(
vertx: Vertx?,
unixDomainSocketPath: String, database: String,
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf()
): PgPool =
createPeerAuthenticationUnixDomainSocketGenericPgClient<PgPool, PoolOptions>(
vertx, unixDomainSocketPath, database, extraPgConnectOptions, poolOptions, PgPool::pool
): Pool =
createPeerAuthenticationUnixDomainSocketGenericPgClient<Pool, PoolOptions>(
vertx, unixDomainSocketPath, database, extraPgConnectOptions, poolOptions, Pool::pool
)

fun createPeerAuthenticationUnixDomainSocketPgPoolAndSetRole(
vertx: Vertx?,
host: String, database: String, role: String,
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf()
): PgPool =
): Pool =
createPeerAuthenticationUnixDomainSocketPgPool(vertx, host, database, extraPgConnectOptions, poolOptions)
.connectHandler {
CoroutineScope(Dispatchers.Unconfined).launch {
Expand Down

0 comments on commit e959812

Please sign in to comment.