Skip to content

Commit

Permalink
refactor: Add connectTimeout (#357)
Browse files Browse the repository at this point in the history
fix: Default value of initQueryTimeout
  • Loading branch information
jakubjanecek authored Oct 20, 2020
1 parent adc2909 commit 052ac1b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ object CassandraDatastaxDriverModule {
stringProperty(LOAD_BALANCING_POLICY_CLASS)(cfg.basic.loadBalancingPolicy.`class`),
optional(stringProperty(LOAD_BALANCING_LOCAL_DATACENTER), cfg.basic.loadBalancingPolicy.localDatacenter),
optional(stringProperty(LOAD_BALANCING_FILTER_CLASS), cfg.basic.loadBalancingPolicy.filter.map(_.`class`)),
durationProperty(CONNECTION_CONNECT_TIMEOUT)(cfg.advanced.connection.connectTimeout),
durationProperty(CONNECTION_INIT_QUERY_TIMEOUT)(cfg.advanced.connection.initQueryTimeout),
intProperty(CONNECTION_POOL_LOCAL_SIZE)(cfg.advanced.connection.localPool.size),
intProperty(CONNECTION_POOL_REMOTE_SIZE)(cfg.advanced.connection.remotePool.size),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ object AdvancedRequestConfig {
* @param warnOnInitError Whether to log non-fatal errors when the driver tries to open a new connection.
*/
final case class ConnectionConfig(
connectTimeout: Duration = ConnectionConfig.Default.connectTimeout,
initQueryTimeout: Duration = ConnectionConfig.Default.initQueryTimeout,
setKeyspaceTimeout: Duration = ConnectionConfig.Default.setKeyspaceTimeout,
localPool: PoolConfig = ConnectionConfig.Default.localPool,
Expand All @@ -145,7 +146,7 @@ final case class ConnectionConfig(

object ConnectionConfig {
val Default: ConnectionConfig =
ConnectionConfig(InitQueryTimeout, InitQueryTimeout, PoolConfig.Default, PoolConfig.Default, 1024, 256, true)
ConnectionConfig(ConnectTimeout, InitQueryTimeout, InitQueryTimeout, PoolConfig.Default, PoolConfig.Default, 1024, 256, true)
}

/** The driver maintains a connection pool to each node, according to the distance assigned to it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package com.avast.sst.datastax
import scala.concurrent.duration._

package object config {
val InitQueryTimeout: Duration = 500.milliseconds
val ConnectTimeout: Duration = 5.seconds
val InitQueryTimeout: Duration = 5.seconds
val RequestTimeout: Duration = 2.seconds
val RequestPageSize: Int = 5000
}

0 comments on commit 052ac1b

Please sign in to comment.