-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the MySQL module with the "mysql" directory copied from the "post…
…gresql" directory
- Loading branch information
Showing
7 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import com.huanshankeji.cpnProject | ||
|
||
plugins { | ||
`lib-conventions` | ||
} | ||
|
||
dependencies { | ||
with(commonDependencies.vertx) { implementation(platformStackDepchain()) } // needed | ||
implementation(cpnProject(project, ":core")) | ||
|
||
runtimeOnly(commonDependencies.postgreSql()) | ||
implementation(commonDependencies.vertx.moduleWithoutVersion("pg-client")) | ||
implementation(commonDependencies.kotlinCommon.core()) // for `Untested` | ||
implementation(commonDependencies.kotlinCommon.vertx()) // for `PgPoolOptions.setUpConventionally` | ||
} |
9 changes: 9 additions & 0 deletions
9
mysql/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/DatabaseClient.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
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 <T> DatabaseClient<Pool>.withPgTransaction(function: suspend (DatabaseClient<PgConnection>) -> T): T = | ||
withTypedTransaction(function) |
33 changes: 33 additions & 0 deletions
33
...main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/exposed/ExposedDatabases.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package com.huanshankeji.exposedvertxsqlclient.postgresql.exposed | ||
|
||
import com.huanshankeji.exposedvertxsqlclient.ConnectionConfig | ||
import com.huanshankeji.exposedvertxsqlclient.ExperimentalEvscApi | ||
import com.huanshankeji.exposedvertxsqlclient.exposed.exposedDatabaseConnect | ||
import org.jetbrains.exposed.sql.Database | ||
import org.jetbrains.exposed.sql.DatabaseConfig | ||
import org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManager | ||
import org.jetbrains.exposed.sql.transactions.TransactionManager | ||
import java.sql.Connection | ||
|
||
/** | ||
* @see exposedDatabaseConnect | ||
*/ | ||
@ExperimentalEvscApi | ||
fun ConnectionConfig.Socket.exposedDatabaseConnectPostgresql( | ||
setupConnection: (Connection) -> Unit = {}, | ||
databaseConfig: DatabaseConfig? = null, | ||
manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) } | ||
) = | ||
exposedDatabaseConnect( | ||
"postgresql", "org.postgresql.Driver", setupConnection, databaseConfig, manager | ||
) | ||
|
||
@ExperimentalEvscApi | ||
@JvmName("exposedDatabaseConnectPostgresqlWithParameterConnectionConfig") | ||
fun exposedDatabaseConnectPostgresql( | ||
socketConnectionConfig: ConnectionConfig.Socket, | ||
setupConnection: (Connection) -> Unit = {}, | ||
databaseConfig: DatabaseConfig? = null, | ||
manager: (Database) -> TransactionManager = { ThreadLocalTransactionManager(it) } | ||
) = | ||
socketConnectionConfig.exposedDatabaseConnectPostgresql(setupConnection, databaseConfig, manager) |
16 changes: 16 additions & 0 deletions
16
...n/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/local/LocalConnectionConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.huanshankeji.exposedvertxsqlclient.postgresql.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" | ||
|
||
@ExperimentalEvscApi | ||
fun defaultPostgresqlLocalConnectionConfig( | ||
socketConnectionPort: Int? = null, user: String, socketConnectionPassword: String, database: String | ||
) = | ||
LocalConnectionConfig( | ||
socketConnectionPort, DEFAULT_POSTGRESQL_UNIX_DOMAIN_SOCKET_PATH, user, socketConnectionPassword, database | ||
) |
103 changes: 103 additions & 0 deletions
103
...main/kotlin/com/huanshankeji/exposedvertxsqlclient/postgresql/vertx/pgclient/PgClients.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
@file:OptIn(ExperimentalEvscApi::class) | ||
|
||
package com.huanshankeji.exposedvertxsqlclient.postgresql.vertx.pgclient | ||
|
||
import com.huanshankeji.Untested | ||
import com.huanshankeji.exposedvertxsqlclient.ConnectionConfig | ||
import com.huanshankeji.exposedvertxsqlclient.ExperimentalEvscApi | ||
import com.huanshankeji.exposedvertxsqlclient.vertx.sqlclient.CoConnectHandler | ||
import com.huanshankeji.exposedvertxsqlclient.vertx.sqlclient.createGenericSqlClient | ||
import com.huanshankeji.exposedvertxsqlclient.vertx.sqlclient.createGenericSqlClientWithBuilder | ||
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 | ||
|
||
/** | ||
* @see createGenericSqlClient | ||
*/ | ||
// made not inline anymore for easier debugging | ||
@ExperimentalEvscApi | ||
fun <SqlClientT : SqlClient, ClientBuilderT : ClientBuilder<SqlClientT>> createGenericPgClientWithBuilder( | ||
vertx: Vertx?, | ||
connectionConfig: ConnectionConfig, | ||
clientBuilder: ClientBuilderT, | ||
extraPgConnectOptions: PgConnectOptions.() -> Unit, | ||
extraPgPoolOptions: PgPoolOptions.() -> Unit, | ||
connectHandlerExtra: CoConnectHandler | ||
): SqlClientT = | ||
createGenericSqlClientWithBuilder( | ||
vertx, | ||
connectionConfig, | ||
clientBuilder, | ||
PgConnectOptions(), | ||
extraPgConnectOptions, | ||
extraPgPoolOptions, | ||
connectHandlerExtra, | ||
PgPoolOptions() | ||
) | ||
|
||
fun createPgClient( | ||
vertx: Vertx?, | ||
connectionConfig: ConnectionConfig, | ||
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, | ||
extraPoolOptions: PgPoolOptions.() -> Unit = {}, | ||
connectHandlerExtra: CoConnectHandler = null, | ||
): SqlClient = | ||
createGenericPgClientWithBuilder( | ||
vertx, | ||
connectionConfig, | ||
PgBuilder.client(), | ||
extraPgConnectOptions, | ||
extraPoolOptions, | ||
connectHandlerExtra | ||
) | ||
|
||
/** | ||
* [PgPoolOptions.pipelined] is enabled by default. | ||
* @see PgPoolOptions.setUpConventionally | ||
* @see createGenericSqlClient | ||
*/ | ||
fun createPgPool( | ||
vertx: Vertx?, | ||
connectionConfig: ConnectionConfig, | ||
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, | ||
extraPoolOptions: PgPoolOptions.() -> Unit = {}, | ||
connectHandlerExtra: CoConnectHandler = null, | ||
): Pool = | ||
createGenericPgClientWithBuilder( | ||
vertx, | ||
connectionConfig, | ||
PgBuilder.pool(), | ||
extraPgConnectOptions, | ||
{ | ||
setUpConventionally() | ||
extraPoolOptions() | ||
}, | ||
connectHandlerExtra | ||
) | ||
|
||
/** | ||
* @see createGenericSqlClient | ||
*/ | ||
@Untested | ||
suspend fun createPgConnection( | ||
vertx: Vertx?, | ||
connectionConfig: ConnectionConfig, | ||
extraPgConnectOptions: PgConnectOptions.() -> Unit = {}, | ||
connectHandlerExtra: CoConnectHandler = null | ||
): PgConnection = | ||
createGenericSqlConnection( | ||
vertx, | ||
connectionConfig, | ||
PgConnection::connect, | ||
PgConnectOptions(), | ||
extraPgConnectOptions, | ||
connectHandlerExtra | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters