diff --git a/README.md b/README.md index 7032a7d..fd5d416 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,7 @@ val evscConfig = defaultPostgresqlLocalConnectionConfig( ).toPerformantUnixEvscConfig() ``` -Create an Exposed `Database` with the `ConnectionConfig.Socket`, which can be reused for multiple `Verticle`s: +Create an Exposed `Database` with the `ConnectionConfig.Socket`, which can be shared and reused in multiple `Verticle`s: ```kotlin val exposedDatabase = evscConfig.exposedConnectionConfig.exposedDatabaseConnectPostgresql() @@ -82,13 +82,15 @@ val exposedDatabase = evscConfig.exposedConnectionConfig.exposedDatabaseConnectP Create a Vert.x `SqlClient` with the `ConnectionConfig`, preferably in a `Verticle`: ```kotlin -val vertxPool = createPgPool(vertx, evscConfig.vertxSqlClientConnectionConfig) +val sqlClient = createPgClient(vertx, evscConfig.vertxSqlClientConnectionConfig) +val pool = createPgPool(vertx, evscConfig.vertxSqlClientConnectionConfig) +val sqlConnection = createPgClient(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) +val databaseClient = DatabaseClient(vertxSqlClient, exposedDatabase) ``` ### Example table definitions diff --git a/integrated/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/Examples.kt b/integrated/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/Examples.kt index 5e3b590..d451c09 100644 --- a/integrated/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/Examples.kt +++ b/integrated/src/main/kotlin/com/huanshankeji/exposedvertxsqlclient/Examples.kt @@ -6,6 +6,7 @@ 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.createPgClient import com.huanshankeji.exposedvertxsqlclient.postgresql.vertx.pgclient.createPgPool import com.huanshankeji.exposedvertxsqlclient.sql.* import io.vertx.core.Verticle @@ -40,10 +41,16 @@ object Alternative { @OptIn(ExperimentalEvscApi::class) suspend fun examples(vertx: Vertx) { - /** It may be more efficient to use a single shared [Database] to generate SQLs for multiple [DatabaseClient]s/[SqlClient]s in respective [Verticle]s. */ + /** It may be more efficient to reuse a single shared [Database] to generate SQLs in multiple [DatabaseClient]s for [SqlClient]s in respective [Verticle]s. */ val exposedDatabase = evscConfig.exposedConnectionConfig.exposedDatabaseConnectPostgresql() - val vertxPool = createPgPool(vertx, evscConfig.vertxSqlClientConnectionConfig) - val databaseClient = DatabaseClient(vertxPool, exposedDatabase) + + val sqlClient = createPgClient(vertx, evscConfig.vertxSqlClientConnectionConfig) + val pool = createPgPool(vertx, evscConfig.vertxSqlClientConnectionConfig) + val sqlConnection = createPgClient(vertx, evscConfig.vertxSqlClientConnectionConfig) + + val vertxSqlClient = sqlClient + + val databaseClient = DatabaseClient(vertxSqlClient, exposedDatabase) withContext(Dispatchers.IO) { databaseClient.exposedTransaction {