From e95981226b7bb48879b80083eb3f6ccba9670d35 Mon Sep 17 00:00:00 2001 From: Yongshun Shreck Ye Date: Sat, 16 Nov 2024 03:41:02 +0800 Subject: [PATCH] Get rid of usages of `PgPool` which was deprecated in 4.5 --- .../exposedvertxsqlclient/DatabaseClient.kt | 5 ++--- .../exposedvertxsqlclient/VertxSqlClients.kt | 22 +++++++++++++------ 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/core/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/DatabaseClient.kt b/core/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/DatabaseClient.kt index acf1e90..988bcda 100644 --- a/core/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/DatabaseClient.kt +++ b/core/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/DatabaseClient.kt @@ -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 @@ -473,7 +472,7 @@ fun createPgPoolDatabaseClient( vertxSqlClientConnectionConfig: ConnectionConfig, extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf(), exposedDatabase: Database -): DatabaseClient = +): DatabaseClient = DatabaseClient( with(vertxSqlClientConnectionConfig) { when (this) { @@ -494,7 +493,7 @@ fun createPgPoolDatabaseClient( vertxSqlClientConnectionConfig: ConnectionConfig, extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf(), exposedSocketConnectionConfig: Socket -): DatabaseClient = +): DatabaseClient = createPgPoolDatabaseClient( vertx, vertxSqlClientConnectionConfig, extraPgConnectOptions, poolOptions, exposedDatabaseConnectPostgreSql(exposedSocketConnectionConfig) diff --git a/core/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/VertxSqlClients.kt b/core/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/VertxSqlClients.kt index 6ec1cc3..dce1ddd 100644 --- a/core/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/VertxSqlClients.kt +++ b/core/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/VertxSqlClients.kt @@ -55,11 +55,16 @@ inline fun 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( vertx, host, port, database, user, password, extraPgConnectOptions, poolOptions, PgPool::client ) @@ -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( - vertx, host, port, database, user, password, extraPgConnectOptions, poolOptions, PgPool::pool +): Pool = + createSocketGenericPgClient( + vertx, host, port, database, user, password, extraPgConnectOptions, poolOptions, Pool::pool ) @Untested @@ -103,15 +108,18 @@ inline fun 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( 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, @@ -128,16 +136,16 @@ fun createPeerAuthenticationUnixDomainSocketPgPool( vertx: Vertx?, unixDomainSocketPath: String, database: String, extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, poolOptions: PoolOptions = poolOptionsOf() -): PgPool = - createPeerAuthenticationUnixDomainSocketGenericPgClient( - vertx, unixDomainSocketPath, database, extraPgConnectOptions, poolOptions, PgPool::pool +): Pool = + createPeerAuthenticationUnixDomainSocketGenericPgClient( + 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 {