Skip to content

Commit 044f90b

Browse files
committed
add pool configuration
1 parent 9e1399c commit 044f90b

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

db-async-common/src/main/java/com/github/jasync/sql/db/ConnectionPoolConfiguration.kt

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ import kotlinx.coroutines.Dispatchers
4949
* @param interceptors optional delegates to call on query execution
5050
* @param maxConnectionTtl number of milliseconds an object in this pool should be kept alive, negative values mean no aging out
5151
* @param currentSchema optional search_path for the database
52+
* @param socketPath path to unix domain socket file (on the local machine)
5253
*
5354
*/
5455
data class ConnectionPoolConfiguration @JvmOverloads constructor(
@@ -74,7 +75,8 @@ data class ConnectionPoolConfiguration @JvmOverloads constructor(
7475
val applicationName: String? = null,
7576
val interceptors: List<Supplier<QueryInterceptor>> = emptyList(),
7677
val maxConnectionTtl: Long? = null,
77-
val currentSchema: String? = null
78+
val currentSchema: String? = null,
79+
val socketPath: String? = null
7880
) {
7981
init {
8082
require(port > 0) { "port should be positive: $port" }
@@ -105,7 +107,8 @@ data class ConnectionPoolConfiguration @JvmOverloads constructor(
105107
interceptors = interceptors,
106108
executionContext = executionContext,
107109
eventLoopGroup = eventLoopGroup,
108-
currentSchema = currentSchema
110+
currentSchema = currentSchema,
111+
socketPath = socketPath
109112
)
110113

111114
val poolConfiguration = PoolConfiguration(
@@ -121,7 +124,7 @@ data class ConnectionPoolConfiguration @JvmOverloads constructor(
121124
)
122125

123126
override fun toString() = """ConnectionPoolConfiguration(host=$host, port=REDACTED,
124-
|database=$database,username=REDACTED, password=REDACTED,
127+
|database=$database,username=REDACTED, password=REDACTED, socketPath=REDACTED,
125128
|currentSchema=$currentSchema
126129
|maxActiveConnections=$maxActiveConnections,
127130
|maxIdleTime=$maxIdleTime,
@@ -135,7 +138,9 @@ data class ConnectionPoolConfiguration @JvmOverloads constructor(
135138
|maximumMessageSize=$maximumMessageSize,
136139
|allocator=$allocator,
137140
|applicationName=$applicationName,
138-
|interceptors=$interceptors, maxConnectionTtl=$maxConnectionTtl)""".trimMargin()
141+
|interceptors=$interceptors,
142+
|maxConnectionTtl=$maxConnectionTtl
143+
|)""".trimMargin()
139144
}
140145

141146
/**
@@ -166,7 +171,8 @@ data class ConnectionPoolConfigurationBuilder @JvmOverloads constructor(
166171
var applicationName: String? = null,
167172
var interceptors: MutableList<Supplier<QueryInterceptor>> = mutableListOf<Supplier<QueryInterceptor>>(),
168173
var maxConnectionTtl: Long? = null,
169-
var currentSchema: String? = null
174+
var currentSchema: String? = null,
175+
var socketPath: String? = null
170176
) {
171177
fun build(): ConnectionPoolConfiguration = ConnectionPoolConfiguration(
172178
host = host,
@@ -190,6 +196,7 @@ data class ConnectionPoolConfigurationBuilder @JvmOverloads constructor(
190196
allocator = allocator,
191197
applicationName = applicationName,
192198
interceptors = interceptors,
193-
currentSchema = currentSchema
199+
currentSchema = currentSchema,
200+
socketPath = socketPath
194201
)
195202
}

0 commit comments

Comments
 (0)