Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split modules, completely overhaul the client creation APIs, and decouple PostgreSQL, our SQL DSL APIs, and our mapper SQL DSL APIs #16

Open
wants to merge 26 commits into
base: dev-dependent-on-snapshots
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
c534750
Create modules/subprojects to split code into, and move the example a…
ShreckYe Nov 15, 2024
58f65e3
Run `apiDump` and remove the old dumped "exposed-vertx-sql-client-pos…
ShreckYe Nov 15, 2024
e101fc8
Add an additional dependency on the "core" module for the benchmark c…
ShreckYe Nov 15, 2024
7b0fc9f
Generalize the functions in "DatabaseClient.kt" using `PgPool` and `P…
ShreckYe Nov 15, 2024
e959812
Get rid of usages of `PgPool` which was deprecated in 4.5
ShreckYe Nov 15, 2024
dfd0d3b
Initially overhaul and reorganize the APIs
ShreckYe Nov 16, 2024
6b1547e
Move "VertxSqlClients.kt"
ShreckYe Nov 17, 2024
21d34c5
Move code related only to PostgreSQL into the `postgresql` subpackage
ShreckYe Nov 17, 2024
603dbb7
Remove a TODO which was already achieved in commit dfd0d3b5762b044c37…
ShreckYe Nov 17, 2024
fdc2023
Completely overhaul the client creation APIs
ShreckYe Nov 19, 2024
198ebf2
Update README.md
ShreckYe Nov 19, 2024
d4773cd
Remove the factory interfaces which are not needed any more with the …
ShreckYe Nov 19, 2024
496c354
Remove default arguments in the `createGeneric...` functions because …
ShreckYe Nov 19, 2024
82b23fa
Extract a `withCoConnectHandle` extension function
ShreckYe Nov 19, 2024
cecd5be
Move a TODO
ShreckYe Nov 19, 2024
d0e1f3e
Add a "sql-dsl" module
ShreckYe Nov 19, 2024
ef6d3d1
Move some code to https://github.com/huanshankeji/kotlin-common
ShreckYe Nov 19, 2024
daf69d7
Resolve a build issue in the `benchmarks` source set of the "integrat…
ShreckYe Nov 19, 2024
2d7b2a5
Move all the code in the package `postgresql` into the "postgresql" m…
ShreckYe Nov 19, 2024
59a26a6
Move the code that belongs to the modules "sql-dsl" and "sql-dsl-with…
ShreckYe Nov 19, 2024
6eb83a7
Run `apiDump` and ensure that `check` is successful
ShreckYe Nov 19, 2024
263cc5c
Print the number of processors and add a comment in `multiThreadMulti…
ShreckYe Nov 19, 2024
210529d
Add `multiThreadConcurrent10KTransactionsWithThreadLocalDatabases` an…
ShreckYe Nov 19, 2024
3715550
Fix a bug that `awaitAny` is used
ShreckYe Nov 19, 2024
920627f
Make `CoroutineScope` the receiver in `awaitAsync10KTransactions` and…
ShreckYe Nov 19, 2024
9a93c0e
Merge branch 'improve-benchmark' into split-modules-and-decouple
ShreckYe Nov 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,39 @@ Here is a basic usage guide. This project currently serves our own use, therefor

### Create a `DatabaseClient`

Create an `EvscConfig` as the single source of truth:

```kotlin
val evscConfig = ConnectionConfig.Socket("localhost", user = "user", password = "password", database = "database")
.toUniversalEvscConfig()
```

Local alternative with Unix domain socket:

```kotlin
val evscConfig = defaultPostgresqlLocalConnectionConfig(
user = "user",
socketConnectionPassword = "password",
database = "database"
).toPerformantUnixEvscConfig()
```

Create an Exposed `Database` with the `ConnectionConfig.Socket`, which can be reused for multiple `Verticle`s:

```kotlin
val socketConnectionConfig =
ConnectionConfig.Socket("localhost", user = "user", password = "password", database = "database")
val exposedDatabase = exposedDatabaseConnectPostgreSql(socketConnectionConfig)
val databaseClient = createPgPoolDatabaseClient(
vertx, socketConnectionConfig, exposedDatabase = exposedDatabase
)
val exposedDatabase = evscConfig.exposedConnectionConfig.exposedDatabaseConnectPostgresql()
```

Create a Vert.x `SqlClient` with the `ConnectionConfig`, preferably in a `Verticle`:

```kotlin
val vertxPool = createPgPool(vertx, evscConfig.vertxSqlClientConnectionConfig)
```

Create a `Database` with the provided Vert.x `SqlClient` and Exposed `Database`, preferably in a `Verticle`:

```kotlin
val databaseClient = DatabaseClient(vertxPool, exposedDatabase)
```

### Example table definitions
Expand Down Expand Up @@ -97,6 +123,8 @@ val exampleName1 =
val exampleName2 =
databaseClient.selectSingleColumn(Examples, Examples.name) { where(Examples.id eq 2) }.single()

val examplesExist = databaseClient.selectExpression(exists(Examples.selectAll()))

val deleteRowCount1 = databaseClient.deleteWhere(Examples) { id eq 1 }
assert(deleteRowCount1 == 1)
val deleteRowCount2 = databaseClient.deleteIgnoreWhere(Examples) { id eq 2 }
Expand Down
12 changes: 1 addition & 11 deletions buildSrc/src/main/kotlin/conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
import com.huanshankeji.team.`Shreck Ye`
import com.huanshankeji.team.pomForTeamDefaultOpenSource
import com.huanshankeji.team.repositoriesAddTeamGithubPackagesMavenRegistry
import org.gradle.kotlin.dsl.repositories

plugins {
id("com.huanshankeji.team.with-group")
id("com.huanshankeji.kotlin-jvm-library-sonatype-ossrh-publish-conventions")
id("com.huanshankeji.team.default-github-packages-maven-publish")
kotlin("jvm")
}

repositories {
Expand All @@ -18,9 +14,3 @@ repositoriesAddTeamGithubPackagesMavenRegistry("kotlin-common")
kotlin.jvmToolchain(8)

version = projectVersion

publishing.publications.getByName<MavenPublication>("maven") {
pomForTeamDefaultOpenSource(project, "Exposed Vert.x SQL Client", "Exposed on top of Vert.x Reactive SQL Client") {
`Shreck Ye`()
}
}
20 changes: 20 additions & 0 deletions buildSrc/src/main/kotlin/lib-conventions.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import com.huanshankeji.team.`Shreck Ye`
import com.huanshankeji.team.pomForTeamDefaultOpenSource
import org.jetbrains.kotlin.gradle.tasks.KotlinCompilationTask

plugins {
id("conventions")
id("com.huanshankeji.kotlin-jvm-library-sonatype-ossrh-publish-conventions")
id("com.huanshankeji.team.default-github-packages-maven-publish")
id("com.huanshankeji.team.dokka.github-dokka-convention")
}

publishing.publications.getByName<MavenPublication>("maven") {
pomForTeamDefaultOpenSource(project, "Exposed Vert.x SQL Client", "Exposed on top of Vert.x Reactive SQL Client") {
`Shreck Ye`()
}
}

tasks.named<KotlinCompilationTask<*>>("compileKotlin").configure {
compilerOptions.freeCompilerArgs.add("-opt-in=com.huanshankeji.exposedvertxsqlclient.InternalApi")
}
171 changes: 171 additions & 0 deletions core/api/exposed-vertx-sql-client-core.api

Large diffs are not rendered by default.

23 changes: 1 addition & 22 deletions lib/build.gradle.kts → core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
plugins {
conventions
id("com.huanshankeji.benchmark.kotlinx-benchmark-jvm-conventions")
id("com.huanshankeji.team.dokka.github-dokka-convention")
`lib-conventions`
}

dependencies {
api(commonDependencies.exposed.core()) // TODO: use `implementation` when possible
// TODO: remove the Exposed JDBC dependency and the PostgresSQL dependency when there is no need to to generate SQLs with an Exposed transaction
runtimeOnly(commonDependencies.exposed.module("jdbc"))
api(commonDependencies.kotlinCommon.exposed())
implementation("com.huanshankeji:exposed-adt-mapping:${DependencyVersions.exposedAdtMapping}")

with(commonDependencies.vertx) {
implementation(platformStackDepchain())
Expand All @@ -24,21 +21,3 @@ dependencies {

implementation(commonDependencies.kotlinCommon.net())
}


// for PostgreSQL
dependencies {
runtimeOnly(commonDependencies.postgreSql())
implementation(commonDependencies.vertx.moduleWithoutVersion("pg-client"))
}

afterEvaluate {
// for the benchmarks
dependencies {
with(commonDependencies.testContainers) {
"benchmarksImplementation"(platformBom())
"benchmarksImplementation"(postgreSql)
}
"benchmarksImplementation"(commonDependencies.slf4j.simple())
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.huanshankeji.exposedvertxsqlclient

import com.huanshankeji.exposedvertxsqlclient.vertx.sqlclient.setRole

sealed interface ConnectionConfig {
val userAndRole: String
val database: String
Expand All @@ -14,11 +16,17 @@ sealed interface ConnectionConfig {
override val userAndRole: String get() = user
}

/**
* @see setRole
*/
class UnixDomainSocketWithPeerAuthentication(
val path: String,
val role: String,
override val database: String
) : ConnectionConfig {
override val userAndRole: String get() = role
}
}
}

fun ConnectionConfig.Socket.toUniversalEvscConfig() =
EvscConfig(this, this)
Loading
Loading