fix(redis): add max pool wait time and switch to ReactiveRedisDataSource for heartbeat updates
Build & Test (NowChessSystems) TeamCity build failed

This commit is contained in:
2026-05-03 16:47:54 +02:00
parent de391113dc
commit 33e5017f51
2 changed files with 11 additions and 2 deletions
@@ -5,6 +5,7 @@ quarkus:
name: nowchess-core name: nowchess-core
redis: redis:
hosts: redis://${REDIS_HOST:localhost}:${REDIS_PORT:6379} hosts: redis://${REDIS_HOST:localhost}:${REDIS_PORT:6379}
max-pool-wait-time: 500ms
grpc: grpc:
clients: clients:
rule-grpc: rule-grpc:
@@ -8,6 +8,7 @@ import io.quarkus.runtime.ShutdownEvent
import io.quarkus.grpc.GrpcClient import io.quarkus.grpc.GrpcClient
import org.eclipse.microprofile.config.inject.ConfigProperty import org.eclipse.microprofile.config.inject.ConfigProperty
import io.quarkus.redis.datasource.RedisDataSource import io.quarkus.redis.datasource.RedisDataSource
import io.quarkus.redis.datasource.ReactiveRedisDataSource
import scala.compiletime.uninitialized import scala.compiletime.uninitialized
import java.util.concurrent.{Executors, TimeUnit} import java.util.concurrent.{Executors, TimeUnit}
import java.net.InetAddress import java.net.InetAddress
@@ -24,6 +25,9 @@ class InstanceHeartbeatService:
@Inject @Inject
private var redis: RedisDataSource = uninitialized private var redis: RedisDataSource = uninitialized
@Inject
private var reactiveRedis: ReactiveRedisDataSource = uninitialized
@Inject @Inject
private var mapper: ObjectMapper = uninitialized private var mapper: ObjectMapper = uninitialized
@@ -182,10 +186,14 @@ class InstanceHeartbeatService:
) )
val json = mapper.writeValueAsString(metadata) val json = mapper.writeValueAsString(metadata)
redis.value(classOf[String]).setex(key, 5L, json) reactiveRedis.value(classOf[String]).setex(key, 5L, json)
.subscribe().`with`(
_ => (),
(ex: Throwable) => log.warnf(ex, "Failed to refresh Redis heartbeat"),
)
catch catch
case ex: Exception => case ex: Exception =>
log.warnf(ex, "Failed to refresh Redis heartbeat") log.warnf(ex, "Failed to serialize Redis heartbeat metadata")
private def getHostname: String = private def getHostname: String =
try InetAddress.getLocalHost.getHostName try InetAddress.getLocalHost.getHostName