diff --git a/imports/java/io/r2dbc/pool/BUILD.bazel b/imports/java/io/r2dbc/pool/BUILD.bazel deleted file mode 100644 index 6d24fcab6..000000000 --- a/imports/java/io/r2dbc/pool/BUILD.bazel +++ /dev/null @@ -1,6 +0,0 @@ -package(default_visibility = ["//visibility:public"]) - -alias( - name = "pool", - actual = "@maven//:io_r2dbc_r2dbc_pool", -) diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel index acf5c4665..82678eb64 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/BUILD.bazel @@ -15,7 +15,6 @@ kt_jvm_library( srcs = ["PostgresConnectionFactories.kt"], deps = [ "//imports/java/com/google/cloud/sql:r2dbc-core", - "//imports/java/io/r2dbc/pool", "//imports/java/org/postgresql:r2dbc", "//src/main/kotlin/org/wfanet/measurement/gcloud/postgres:flags", ], diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresConnectionFactories.kt b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresConnectionFactories.kt index febe74ba2..8bfd6d519 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresConnectionFactories.kt +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresConnectionFactories.kt @@ -15,8 +15,6 @@ package org.wfanet.measurement.gcloud.postgres import com.google.cloud.sql.core.GcpConnectionFactoryProvider -import io.r2dbc.pool.ConnectionPool -import io.r2dbc.pool.ConnectionPoolConfiguration import io.r2dbc.spi.ConnectionFactories import io.r2dbc.spi.ConnectionFactory import io.r2dbc.spi.ConnectionFactoryOptions @@ -24,28 +22,17 @@ import io.r2dbc.spi.ConnectionFactoryOptions object PostgresConnectionFactories { @JvmStatic fun buildConnectionFactory(flags: PostgresFlags): ConnectionFactory { - val connectionFactory = - ConnectionFactories.get( - ConnectionFactoryOptions.builder() - .option(ConnectionFactoryOptions.DRIVER, "gcp") - .option(ConnectionFactoryOptions.PROTOCOL, "postgresql") - .option(ConnectionFactoryOptions.USER, flags.user) - // a non-empty password is required, but the value doesn't matter - .option(ConnectionFactoryOptions.PASSWORD, "UNUSED") - .option(ConnectionFactoryOptions.DATABASE, flags.database) - .option(ConnectionFactoryOptions.HOST, flags.cloudSqlInstance) - .option(ConnectionFactoryOptions.STATEMENT_TIMEOUT, flags.statementTimeout) - .option(GcpConnectionFactoryProvider.ENABLE_IAM_AUTH, true) - .build() - ) - - val configuration: ConnectionPoolConfiguration = - ConnectionPoolConfiguration.builder(connectionFactory) - .maxIdleTime(flags.maxIdleTime) - .maxSize(flags.maxPoolSize) - .acquireRetry(flags.acquireRetry) + return ConnectionFactories.get( + ConnectionFactoryOptions.builder() + .option(ConnectionFactoryOptions.DRIVER, "gcp") + .option(ConnectionFactoryOptions.PROTOCOL, "postgresql") + .option(ConnectionFactoryOptions.USER, flags.user) + // a non-empty password is required, but the value doesn't matter + .option(ConnectionFactoryOptions.PASSWORD, "UNUSED") + .option(ConnectionFactoryOptions.DATABASE, flags.database) + .option(ConnectionFactoryOptions.HOST, flags.cloudSqlInstance) + .option(GcpConnectionFactoryProvider.ENABLE_IAM_AUTH, true) .build() - - return ConnectionPool(configuration) + ) } } diff --git a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresFlags.kt b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresFlags.kt index 094ac72ad..7cbf54d15 100644 --- a/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresFlags.kt +++ b/src/main/kotlin/org/wfanet/measurement/gcloud/postgres/PostgresFlags.kt @@ -14,8 +14,6 @@ package org.wfanet.measurement.gcloud.postgres -import java.time.Duration -import kotlin.properties.Delegates import picocli.CommandLine /** Common command-line flags for connecting to a single Postgres database. */ @@ -23,7 +21,7 @@ class PostgresFlags { @CommandLine.Option( names = ["--postgres-database"], description = ["Name of the Postgres database."], - required = true, + required = true ) lateinit var database: String private set @@ -31,7 +29,7 @@ class PostgresFlags { @CommandLine.Option( names = ["--postgres-cloud-sql-connection-name"], description = ["Instance connection name of the Postgres database."], - required = true, + required = true ) lateinit var cloudSqlInstance: String private set @@ -39,44 +37,8 @@ class PostgresFlags { @CommandLine.Option( names = ["--postgres-user"], description = ["User of the Postgres database."], - required = true, + required = true ) lateinit var user: String private set - - @CommandLine.Option( - names = ["--statement-timeout"], - description = ["Statement timeout duration."], - required = false, - defaultValue = "120s", - ) - lateinit var statementTimeout: Duration - private set - - @CommandLine.Option( - names = ["--max-idle-time"], - description = ["Maximum duration a connection can be idle before being closed."], - required = false, - defaultValue = "5m", - ) - lateinit var maxIdleTime: Duration - private set - - @set:CommandLine.Option( - names = ["--max-connection-pool-size"], - description = ["Maximum number of connections in pool."], - required = false, - defaultValue = "16", - ) - var maxPoolSize by Delegates.notNull() - private set - - @set:CommandLine.Option( - names = ["--acquire-retry"], - description = ["Maximum number of retries when acquiring a connection from the pool."], - required = false, - defaultValue = "10", - ) - var acquireRetry by Delegates.notNull() - private set }