From bf1b0d34c8ff665edbb1e6f0079ed3a313a0cb28 Mon Sep 17 00:00:00 2001 From: alfred Date: Sat, 18 Jan 2025 07:31:06 +0100 Subject: [PATCH] Update MySQLClients.kt but some problems may be raised, thus a further discussion required --- .../WithContainerizedDatabaseBenchmark.kt | 2 +- .../exposedvertxsqlclient/Examples.kt | 6 +-- mysql/api/exposed-vertx-sql-client-mysql.api | 28 ++++++++++++ .../exposed-vertx-sql-client-postgresql.api | 27 ------------ mysql/build.gradle.kts | 6 ++- .../mysql/DatabaseClient.kt | 9 ++++ .../exposed/ExposedDatabases.kt | 8 ++-- .../local/LocalConnectionConfig.kt | 8 ++-- .../mysql/vertx/mysqlclient/MySQLClients.kt | 44 +++++++++++-------- .../postgresql/DatabaseClient.kt | 9 ---- .../exposed-vertx-sql-client-postgresql.api | 8 ++-- .../{postgresql => mysql}/DatabaseClient.kt | 2 +- .../exposed/ExposedDatabases.kt | 2 +- .../local/LocalConnectionConfig.kt | 2 +- .../mysql/vertx/mysqlclient}/PgClients.kt | 2 +- 15 files changed, 86 insertions(+), 77 deletions(-) create mode 100644 mysql/api/exposed-vertx-sql-client-mysql.api delete mode 100644 mysql/api/exposed-vertx-sql-client-postgresql.api create mode 100644 mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/DatabaseClient.kt rename mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/{postgresql => mysql}/exposed/ExposedDatabases.kt (81%) rename mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/{postgresql => mysql}/local/LocalConnectionConfig.kt (53%) rename postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClients.kt => mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient/MySQLClients.kt (67%) delete mode 100644 mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClient.kt rename postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/{postgresql => mysql}/DatabaseClient.kt (85%) rename postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/{postgresql => mysql}/exposed/ExposedDatabases.kt (95%) rename postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/{postgresql => mysql}/local/LocalConnectionConfig.kt (90%) rename {mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient => postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient}/PgClients.kt (97%) diff --git a/integrated/src/benchmarks/kotlin/com/huanshankeji/exposed/benchmark/WithContainerizedDatabaseBenchmark.kt b/integrated/src/benchmarks/kotlin/com/huanshankeji/exposed/benchmark/WithContainerizedDatabaseBenchmark.kt index 51e21c7..cd9927f 100644 --- a/integrated/src/benchmarks/kotlin/com/huanshankeji/exposed/benchmark/WithContainerizedDatabaseBenchmark.kt +++ b/integrated/src/benchmarks/kotlin/com/huanshankeji/exposed/benchmark/WithContainerizedDatabaseBenchmark.kt @@ -1,7 +1,7 @@ package com.huanshankeji.exposed.benchmark import com.huanshankeji.exposedvertxsqlclient.ConnectionConfig -import com.huanshankeji.exposedvertxsqlclient.postgresql.exposed.exposedDatabaseConnectPostgresql +import com.huanshankeji.exposedvertxsqlclient.mysql.exposed.exposedDatabaseConnectPostgresql import kotlinx.benchmark.Scope import kotlinx.benchmark.Setup import kotlinx.benchmark.State diff --git a/integrated/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/Examples.kt b/integrated/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/Examples.kt index 5e3b590..5e3921e 100644 --- a/integrated/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/Examples.kt +++ b/integrated/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/Examples.kt @@ -4,9 +4,9 @@ package com.huanshankeji.exposedvertxsqlclient import com.huanshankeji.exposed.* import com.huanshankeji.exposedvertxsqlclient.local.toPerformantUnixEvscConfig -import com.huanshankeji.exposedvertxsqlclient.postgresql.exposed.exposedDatabaseConnectPostgresql -import com.huanshankeji.exposedvertxsqlclient.postgresql.local.defaultPostgresqlLocalConnectionConfig -import com.huanshankeji.exposedvertxsqlclient.postgresql.vertx.pgclient.createPgPool +import com.huanshankeji.exposedvertxsqlclient.mysql.exposed.exposedDatabaseConnectPostgresql +import com.huanshankeji.exposedvertxsqlclient.mysql.local.defaultPostgresqlLocalConnectionConfig +import com.huanshankeji.exposedvertxsqlclient.mysql.vertx.mysqlclient.createPgPool import com.huanshankeji.exposedvertxsqlclient.sql.* import io.vertx.core.Verticle import io.vertx.core.Vertx diff --git a/mysql/api/exposed-vertx-sql-client-mysql.api b/mysql/api/exposed-vertx-sql-client-mysql.api new file mode 100644 index 0000000..a64dc84 --- /dev/null +++ b/mysql/api/exposed-vertx-sql-client-mysql.api @@ -0,0 +1,28 @@ +public final class com/huanshankeji/exposedvertxsqlclient/mysql/DatabaseClientKt { + public static final fun withSQLTransaction (Lcom/huanshankeji/exposedvertxsqlclient/DatabaseClient;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; +} + +public final class com/huanshankeji/exposedvertxsqlclient/mysql/exposed/ExposedDatabasesKt { + public static final fun exposedDatabaseConnectMySQL (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Database; + public static synthetic fun exposedDatabaseConnectMySQL$default (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Database; + public static final fun exposedDatabaseConnectMySQLWithParameterConnectionConfig (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Database; + public static synthetic fun exposedDatabaseConnectMySQLWithParameterConnectionConfig$default (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Database; +} + +public final class com/huanshankeji/exposedvertxsqlclient/mysql/local/LocalConnectionConfigKt { + public static final field DEFAULT_MYSQL_UNIX_DOMAIN_SOCKET_PATH Ljava/lang/String; + public static final fun defaultMySQLLocalConnectionConfig (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/huanshankeji/exposedvertxsqlclient/local/LocalConnectionConfig; + public static synthetic fun defaultMySQLLocalConnectionConfig$default (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lcom/huanshankeji/exposedvertxsqlclient/local/LocalConnectionConfig; +} + +public final class com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient/MySQLClientsKt { + public static final fun createGenericPgClientWithBuilder (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lio/vertx/sqlclient/ClientBuilder;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/vertx/sqlclient/SqlClient; + public static final fun createPgClient (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/vertx/sqlclient/SqlClient; + public static synthetic fun createPgClient$default (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lio/vertx/sqlclient/SqlClient; + public static final fun createPgConnection (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; + public static synthetic fun createPgConnection$default (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; + public static final fun createPgPool (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/vertx/sqlclient/Pool; + public static synthetic fun createPgPool$default (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lio/vertx/sqlclient/Pool; + public static final fun setUpConventionally (Lio/vertx/mysqlclient/impl/MySQLPoolOptions;)V +} + diff --git a/mysql/api/exposed-vertx-sql-client-postgresql.api b/mysql/api/exposed-vertx-sql-client-postgresql.api deleted file mode 100644 index 4926d01..0000000 --- a/mysql/api/exposed-vertx-sql-client-postgresql.api +++ /dev/null @@ -1,27 +0,0 @@ -public final class com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClientKt { - public static final fun withPgTransaction (Lcom/huanshankeji/exposedvertxsqlclient/DatabaseClient;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; -} - -public final class com/huanshankeji/exposedvertxsqlclient/postgresql/exposed/ExposedDatabasesKt { - public static final fun exposedDatabaseConnectPostgresql (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Database; - public static synthetic fun exposedDatabaseConnectPostgresql$default (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Database; - public static final fun exposedDatabaseConnectPostgresqlWithParameterConnectionConfig (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Database; - public static synthetic fun exposedDatabaseConnectPostgresqlWithParameterConnectionConfig$default (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Database; -} - -public final class com/huanshankeji/exposedvertxsqlclient/postgresql/local/LocalConnectionConfigKt { - public static final field DEFAULT_POSTGRESQL_UNIX_DOMAIN_SOCKET_PATH Ljava/lang/String; - public static final fun defaultPostgresqlLocalConnectionConfig (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/huanshankeji/exposedvertxsqlclient/local/LocalConnectionConfig; - public static synthetic fun defaultPostgresqlLocalConnectionConfig$default (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lcom/huanshankeji/exposedvertxsqlclient/local/LocalConnectionConfig; -} - -public final class com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClientsKt { - public static final fun createGenericPgClientWithBuilder (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lio/vertx/sqlclient/ClientBuilder;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/vertx/sqlclient/SqlClient; - public static final fun createPgClient (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/vertx/sqlclient/SqlClient; - public static synthetic fun createPgClient$default (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lio/vertx/sqlclient/SqlClient; - public static final fun createPgConnection (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; - public static synthetic fun createPgConnection$default (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object; - public static final fun createPgPool (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/vertx/sqlclient/Pool; - public static synthetic fun createPgPool$default (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lio/vertx/sqlclient/Pool; -} - diff --git a/mysql/build.gradle.kts b/mysql/build.gradle.kts index a872117..cb8fcd8 100644 --- a/mysql/build.gradle.kts +++ b/mysql/build.gradle.kts @@ -7,9 +7,11 @@ plugins { dependencies { with(commonDependencies.vertx) { implementation(platformStackDepchain()) } // needed implementation(cpnProject(project, ":core")) - - runtimeOnly(commonDependencies.postgreSql()) // TODO change to the MySQL JDBC dependency + //runtimeOnly(commonDependencies.postgreSql()) // TODO change to the MySQL JDBC dependency + // cannot modify commonDependencies? + //runtimeOnly(); implementation(commonDependencies.vertx.moduleWithoutVersion("mysql-client")) implementation(commonDependencies.kotlinCommon.core()) // for `Untested` implementation(commonDependencies.kotlinCommon.vertx()) // for `PgPoolOptions.setUpConventionally` // TODO check if this is necessary for MySQL, and remove if not + // this seems to be needed as mentioned in vertx-mysql-client } diff --git a/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/DatabaseClient.kt b/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/DatabaseClient.kt new file mode 100644 index 0000000..e825e46 --- /dev/null +++ b/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/DatabaseClient.kt @@ -0,0 +1,9 @@ +package com.huanshankeji.exposedvertxsqlclient.mysql + +import com.huanshankeji.exposedvertxsqlclient.DatabaseClient +import com.huanshankeji.exposedvertxsqlclient.withTypedTransaction +import io.vertx.sqlclient.Pool +import io.vertx.sqlclient.SqlConnection + +suspend fun DatabaseClient.withSQLTransaction(function: suspend (DatabaseClient) -> T): T = + withTypedTransaction(function) \ No newline at end of file diff --git a/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/exposed/ExposedDatabases.kt b/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/exposed/ExposedDatabases.kt similarity index 81% rename from mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/exposed/ExposedDatabases.kt rename to mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/exposed/ExposedDatabases.kt index 623f632..4a3d68a 100644 --- a/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/exposed/ExposedDatabases.kt +++ b/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/exposed/ExposedDatabases.kt @@ -1,4 +1,4 @@ -package com.huanshankeji.exposedvertxsqlclient.postgresql.exposed +package com.huanshankeji.exposedvertxsqlclient.mysql.exposed import com.huanshankeji.exposedvertxsqlclient.ConnectionConfig import com.huanshankeji.exposedvertxsqlclient.ExperimentalEvscApi @@ -13,7 +13,7 @@ import java.sql.Connection * @see exposedDatabaseConnect */ @ExperimentalEvscApi -fun ConnectionConfig.Socket.exposedDatabaseConnectMysql( +fun ConnectionConfig.Socket.exposedDatabaseConnectMySQL( setupConnection: (Connection) -> Unit = {}, databaseConfig: DatabaseConfig? = null, manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) } @@ -23,11 +23,11 @@ fun ConnectionConfig.Socket.exposedDatabaseConnectMysql( ) @ExperimentalEvscApi -@JvmName("exposedDatabaseConnectPostgresqlWithParameterConnectionConfig") +@JvmName("exposedDatabaseConnectMySQLWithParameterConnectionConfig") fun exposedDatabaseConnectMysql( socketConnectionConfig: ConnectionConfig.Socket, setupConnection: (Connection) -> Unit = {}, databaseConfig: DatabaseConfig? = null, manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) } ) = - socketConnectionConfig.exposedDatabaseConnectMysql(setupConnection, databaseConfig, manager) + socketConnectionConfig.exposedDatabaseConnectMySQL(setupConnection, databaseConfig, manager) diff --git a/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/local/LocalConnectionConfig.kt b/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/local/LocalConnectionConfig.kt similarity index 53% rename from mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/local/LocalConnectionConfig.kt rename to mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/local/LocalConnectionConfig.kt index 6187485..e459438 100644 --- a/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/local/LocalConnectionConfig.kt +++ b/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/local/LocalConnectionConfig.kt @@ -1,16 +1,16 @@ -package com.huanshankeji.exposedvertxsqlclient.postgresql.local +package com.huanshankeji.exposedvertxsqlclient.mysql.local import com.huanshankeji.exposedvertxsqlclient.ExperimentalEvscApi import com.huanshankeji.exposedvertxsqlclient.local.LocalConnectionConfig // TODO consider moving to "kotlin-common" -const val DEFAULT_POSTGRESQL_UNIX_DOMAIN_SOCKET_PATH = "/var/run/postgresql" +const val DEFAULT_MYSQL_UNIX_DOMAIN_SOCKET_PATH = "/var/run/mysql" @ExperimentalEvscApi -fun defaultPostgresqlLocalConnectionConfig( +fun defaultMySQLLocalConnectionConfig( socketConnectionPort: Int? = null, user: String, socketConnectionPassword: String, database: String ) = LocalConnectionConfig( - socketConnectionPort, DEFAULT_POSTGRESQL_UNIX_DOMAIN_SOCKET_PATH, user, socketConnectionPassword, database + socketConnectionPort, DEFAULT_MYSQL_UNIX_DOMAIN_SOCKET_PATH, user, socketConnectionPassword, database ) diff --git a/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClients.kt b/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient/MySQLClients.kt similarity index 67% rename from postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClients.kt rename to mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient/MySQLClients.kt index 21542cd..dea946c 100644 --- a/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClients.kt +++ b/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient/MySQLClients.kt @@ -1,6 +1,6 @@ @file:OptIn(ExperimentalEvscApi::class) -package com.huanshankeji.exposedvertxsqlclient.postgresql.vertx.pgclient +package com.huanshankeji.exposedvertxsqlclient.mysql.vertx.mysqlclient import com.huanshankeji.Untested import com.huanshankeji.exposedvertxsqlclient.ConnectionConfig @@ -11,13 +11,16 @@ import com.huanshankeji.exposedvertxsqlclient.vertx.sqlclient.createGenericSqlCl import com.huanshankeji.exposedvertxsqlclient.vertx.sqlclient.createGenericSqlConnection import com.huanshankeji.vertx.pgclient.setUpConventionally import io.vertx.core.Vertx -import io.vertx.pgclient.PgBuilder -import io.vertx.pgclient.PgConnectOptions -import io.vertx.pgclient.PgConnection -import io.vertx.pgclient.impl.PgPoolOptions import io.vertx.sqlclient.ClientBuilder import io.vertx.sqlclient.Pool import io.vertx.sqlclient.SqlClient +import io.vertx.mysqlclient.MySQLBuilder +import io.vertx.mysqlclient.MySQLConnection +// import io.vertx.mysqlclient.MySQLPool --deprecated +import io.vertx.mysqlclient.MySQLConnectOptions +import io.vertx.mysqlclient.impl.MySQLPoolOptions +import io.vertx.sqlclient.PoolOptions + /** * @see createGenericSqlClient @@ -28,32 +31,32 @@ fun > createG vertx: Vertx?, connectionConfig: ConnectionConfig, clientBuilder: ClientBuilderT, - extraPgConnectOptions: PgConnectOptions.() -> Unit, - extraPgPoolOptions: PgPoolOptions.() -> Unit, + extraPgConnectOptions: MySQLConnectOptions.() -> Unit, + extraPgPoolOptions: MySQLPoolOptions.() -> Unit, connectHandlerExtra: CoConnectHandler ): SqlClientT = createGenericSqlClientWithBuilder( vertx, connectionConfig, clientBuilder, - PgConnectOptions(), + MySQLConnectOptions(), extraPgConnectOptions, extraPgPoolOptions, connectHandlerExtra, - PgPoolOptions() + MySQLPoolOptions(PoolOptions()) // remain to verify ) fun createPgClient( vertx: Vertx?, connectionConfig: ConnectionConfig, - extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, - extraPoolOptions: PgPoolOptions.() -> Unit = {}, + extraPgConnectOptions: MySQLConnectOptions.() -> Unit = {}, + extraPoolOptions: MySQLPoolOptions.() -> Unit = {}, connectHandlerExtra: CoConnectHandler = null, ): SqlClient = createGenericPgClientWithBuilder( vertx, connectionConfig, - PgBuilder.client(), + MySQLBuilder.client(), extraPgConnectOptions, extraPoolOptions, connectHandlerExtra @@ -67,14 +70,14 @@ fun createPgClient( fun createPgPool( vertx: Vertx?, connectionConfig: ConnectionConfig, - extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, - extraPoolOptions: PgPoolOptions.() -> Unit = {}, + extraPgConnectOptions: MySQLConnectOptions.() -> Unit = {}, + extraPoolOptions: MySQLPoolOptions.() -> Unit = {}, connectHandlerExtra: CoConnectHandler = null, ): Pool = createGenericPgClientWithBuilder( vertx, connectionConfig, - PgBuilder.pool(), + MySQLBuilder.pool(), extraPgConnectOptions, { setUpConventionally() @@ -83,6 +86,9 @@ fun createPgPool( connectHandlerExtra ) +// temporarily added, maybe moved into kotlin-common +public fun io.vertx.mysqlclient.impl.MySQLPoolOptions.setUpConventionally(): kotlin.Unit { /* compiled code */ } + /** * @see createGenericSqlClient */ @@ -90,14 +96,14 @@ fun createPgPool( suspend fun createPgConnection( vertx: Vertx?, connectionConfig: ConnectionConfig, - extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, + extraPgConnectOptions: MySQLConnectOptions.() -> Unit = {}, connectHandlerExtra: CoConnectHandler = null -): PgConnection = +): MySQLConnection = createGenericSqlConnection( vertx, connectionConfig, - PgConnection::connect, - PgConnectOptions(), + MySQLConnection::connect, + MySQLConnectOptions(), extraPgConnectOptions, connectHandlerExtra ) diff --git a/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClient.kt b/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClient.kt deleted file mode 100644 index 54ea5d2..0000000 --- a/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClient.kt +++ /dev/null @@ -1,9 +0,0 @@ -package com.huanshankeji.exposedvertxsqlclient.postgresql - -import com.huanshankeji.exposedvertxsqlclient.DatabaseClient -import com.huanshankeji.exposedvertxsqlclient.withTypedTransaction -import io.vertx.pgclient.PgConnection -import io.vertx.sqlclient.Pool - -suspend fun DatabaseClient.withPgTransaction(function: suspend (DatabaseClient) -> T): T = - withTypedTransaction(function) diff --git a/postgresql/api/exposed-vertx-sql-client-postgresql.api b/postgresql/api/exposed-vertx-sql-client-postgresql.api index 4926d01..0aa2da1 100644 --- a/postgresql/api/exposed-vertx-sql-client-postgresql.api +++ b/postgresql/api/exposed-vertx-sql-client-postgresql.api @@ -1,21 +1,21 @@ -public final class com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClientKt { +public final class com/huanshankeji/exposedvertxsqlclient/mysql/DatabaseClientKt { public static final fun withPgTransaction (Lcom/huanshankeji/exposedvertxsqlclient/DatabaseClient;Lkotlin/jvm/functions/Function2;Lkotlin/coroutines/Continuation;)Ljava/lang/Object; } -public final class com/huanshankeji/exposedvertxsqlclient/postgresql/exposed/ExposedDatabasesKt { +public final class com/huanshankeji/exposedvertxsqlclient/mysql/exposed/ExposedDatabasesKt { public static final fun exposedDatabaseConnectPostgresql (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Database; public static synthetic fun exposedDatabaseConnectPostgresql$default (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Database; public static final fun exposedDatabaseConnectPostgresqlWithParameterConnectionConfig (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;)Lorg/jetbrains/exposed/sql/Database; public static synthetic fun exposedDatabaseConnectPostgresqlWithParameterConnectionConfig$default (Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig$Socket;Lkotlin/jvm/functions/Function1;Lorg/jetbrains/exposed/sql/DatabaseConfig;Lkotlin/jvm/functions/Function1;ILjava/lang/Object;)Lorg/jetbrains/exposed/sql/Database; } -public final class com/huanshankeji/exposedvertxsqlclient/postgresql/local/LocalConnectionConfigKt { +public final class com/huanshankeji/exposedvertxsqlclient/mysql/local/LocalConnectionConfigKt { public static final field DEFAULT_POSTGRESQL_UNIX_DOMAIN_SOCKET_PATH Ljava/lang/String; public static final fun defaultPostgresqlLocalConnectionConfig (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Lcom/huanshankeji/exposedvertxsqlclient/local/LocalConnectionConfig; public static synthetic fun defaultPostgresqlLocalConnectionConfig$default (Ljava/lang/Integer;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava/lang/Object;)Lcom/huanshankeji/exposedvertxsqlclient/local/LocalConnectionConfig; } -public final class com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClientsKt { +public final class com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient/PgClientsKt { public static final fun createGenericPgClientWithBuilder (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lio/vertx/sqlclient/ClientBuilder;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/vertx/sqlclient/SqlClient; public static final fun createPgClient (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;)Lio/vertx/sqlclient/SqlClient; public static synthetic fun createPgClient$default (Lio/vertx/core/Vertx;Lcom/huanshankeji/exposedvertxsqlclient/ConnectionConfig;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function2;ILjava/lang/Object;)Lio/vertx/sqlclient/SqlClient; diff --git a/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClient.kt b/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/DatabaseClient.kt similarity index 85% rename from postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClient.kt rename to postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/DatabaseClient.kt index 54ea5d2..e571d8b 100644 --- a/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClient.kt +++ b/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/DatabaseClient.kt @@ -1,4 +1,4 @@ -package com.huanshankeji.exposedvertxsqlclient.postgresql +package com.huanshankeji.exposedvertxsqlclient.mysql import com.huanshankeji.exposedvertxsqlclient.DatabaseClient import com.huanshankeji.exposedvertxsqlclient.withTypedTransaction diff --git a/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/exposed/ExposedDatabases.kt b/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/exposed/ExposedDatabases.kt similarity index 95% rename from postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/exposed/ExposedDatabases.kt rename to postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/exposed/ExposedDatabases.kt index c17199d..fca7679 100644 --- a/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/exposed/ExposedDatabases.kt +++ b/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/exposed/ExposedDatabases.kt @@ -1,4 +1,4 @@ -package com.huanshankeji.exposedvertxsqlclient.postgresql.exposed +package com.huanshankeji.exposedvertxsqlclient.mysql.exposed import com.huanshankeji.exposedvertxsqlclient.ConnectionConfig import com.huanshankeji.exposedvertxsqlclient.ExperimentalEvscApi diff --git a/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/local/LocalConnectionConfig.kt b/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/local/LocalConnectionConfig.kt similarity index 90% rename from postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/local/LocalConnectionConfig.kt rename to postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/local/LocalConnectionConfig.kt index 6187485..832f6f7 100644 --- a/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/local/LocalConnectionConfig.kt +++ b/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/local/LocalConnectionConfig.kt @@ -1,4 +1,4 @@ -package com.huanshankeji.exposedvertxsqlclient.postgresql.local +package com.huanshankeji.exposedvertxsqlclient.mysql.local import com.huanshankeji.exposedvertxsqlclient.ExperimentalEvscApi import com.huanshankeji.exposedvertxsqlclient.local.LocalConnectionConfig diff --git a/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClients.kt b/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient/PgClients.kt similarity index 97% rename from mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClients.kt rename to postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient/PgClients.kt index 21542cd..2ab3ab2 100644 --- a/mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClients.kt +++ b/postgresql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/mysql/vertx/mysqlclient/PgClients.kt @@ -1,6 +1,6 @@ @file:OptIn(ExperimentalEvscApi::class) -package com.huanshankeji.exposedvertxsqlclient.postgresql.vertx.pgclient +package com.huanshankeji.exposedvertxsqlclient.mysql.vertx.mysqlclient import com.huanshankeji.Untested import com.huanshankeji.exposedvertxsqlclient.ConnectionConfig