Skip to content

Commit

Permalink
Split defaults for owned vs shared connections
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherDavenport committed Mar 29, 2024
1 parent 93643a6 commit b64d82d
Showing 1 changed file with 26 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,21 @@ object RedisConnection{
val maxIdle: Int = 100
val maxTotal: Int = 100

val commandTimeout: Duration = 30.seconds // If using a blocking operation this is likely inappropriate.
@deprecated("0.5.2", "Use Defaults.commandTimeout instead")
val requestTimeout: Duration = commandTimeout
// If using a blocking operation these is likely inappropriate.
// You want Command Timeout to be higher than RedisRequestTimeout
val ownedConnectionCommandTimeout: Duration = 10.seconds
val ownedConnectionRedisRequestTimeout: Duration = 5.seconds

// If using a blocking operation this is likely inappropriate.
val sharedConnectionCommandTimeout: Duration = 5.seconds
val sharedConnectionRedisRequestTimeout: Duration = 5.seconds


@deprecated("0.5.2", "Use Defaults.ownedConnectionCommandTimeout or Defaults. instead")
val requestTimeout: Duration = 30.seconds



val redisRequestTimeout = 20.seconds // If using a blocking operation this is likely inappropriate.


// TODO config
Expand All @@ -164,8 +174,8 @@ object RedisConnection{
TLSParameters.Default,
None,
Defaults.useTLS,
Defaults.commandTimeout,
Defaults.redisRequestTimeout,
Defaults.ownedConnectionCommandTimeout,
Defaults.ownedConnectionRedisRequestTimeout,
)

@deprecated("Use overload that takes a Network", "0.4.1")
Expand Down Expand Up @@ -233,9 +243,9 @@ object RedisConnection{
_ <- Resource.eval(auth match {
case None => ().pure[F]
case Some((Some(username), password)) =>
RedisCommands.auth[Redis[F, *]](username, password).run(DirectConnection(out, commandTimeout, redisRequestTimeout)).void
RedisCommands.auth[Redis[F, *]](username, password).run(DirectConnection(out, Duration.Inf, redisRequestTimeout)).void
case Some((None, password)) =>
RedisCommands.auth[Redis[F, *]](password).run(DirectConnection(out, commandTimeout, redisRequestTimeout)).void
RedisCommands.auth[Redis[F, *]](password).run(DirectConnection(out, Duration.Inf, redisRequestTimeout)).void
})
} yield RedisConnection.DirectConnection(out, commandTimeout, redisRequestTimeout)
}
Expand All @@ -252,8 +262,8 @@ object RedisConnection{
Defaults.idleTimeAllowedInPool,
Defaults.maxIdle,
Defaults.maxTotal,
Defaults.commandTimeout,
Defaults.redisRequestTimeout,
Defaults.ownedConnectionCommandTimeout,
Defaults.ownedConnectionRedisRequestTimeout,
)

@deprecated("Use overload that takes a Network", "0.4.1")
Expand Down Expand Up @@ -338,9 +348,9 @@ object RedisConnection{
auth match {
case None => ().pure[F]
case Some((Some(username), password)) =>
RedisCommands.auth[Redis[F, *]](username, password).run(DirectConnection(socket, commandTimeout, redisRequestTimeout)).void
RedisCommands.auth[Redis[F, *]](username, password).run(DirectConnection(socket, Duration.Inf, redisRequestTimeout)).void
case Some((None, password)) =>
RedisCommands.auth[Redis[F, *]](password).run(DirectConnection(socket, commandTimeout, redisRequestTimeout)).void
RedisCommands.auth[Redis[F, *]](password).run(DirectConnection(socket, Duration.Inf, redisRequestTimeout)).void
}
)
}
Expand Down Expand Up @@ -368,8 +378,8 @@ object RedisConnection{
Defaults.idleTimeAllowedInPool,
Defaults.maxIdle,
Defaults.maxTotal,
Defaults.commandTimeout,
Defaults.redisRequestTimeout,
Defaults.sharedConnectionCommandTimeout,
Defaults.sharedConnectionRedisRequestTimeout,
)

@deprecated("Use overload that takes a Network", "0.4.1")
Expand Down Expand Up @@ -537,8 +547,8 @@ object RedisConnection{
Defaults.idleTimeAllowedInPool,
Defaults.maxIdle,
Defaults.maxTotal,
Defaults.commandTimeout,
Defaults.redisRequestTimeout,
Defaults.sharedConnectionCommandTimeout,
Defaults.sharedConnectionRedisRequestTimeout,
)

@deprecated("Use overload that takes a Network", "0.4.1")
Expand Down

0 comments on commit b64d82d

Please sign in to comment.