feat(tournament): seed external server registry from env var on startup
Build & Test (NowChessSystems) TeamCity build was queued
Build & Test (NowChessSystems) TeamCity build was queued
TOURNAMENT_EXTERNAL_SERVERS (comma-separated URLs) is loaded into TournamentServerRegistry at startup so the bot can park on all servers and replication targets are known without manual API calls after each restart. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -27,7 +27,7 @@ nowchess:
|
||||
internal:
|
||||
secret: 123abc
|
||||
tournament:
|
||||
service-url: http://localhost:8086
|
||||
service-url: http://localhost:8088
|
||||
|
||||
"%deployed":
|
||||
quarkus:
|
||||
@@ -52,4 +52,4 @@ nowchess:
|
||||
internal:
|
||||
secret: ${INTERNAL_SECRET}
|
||||
tournament:
|
||||
service-url: ${TOURNAMENT_SERVICE_URL:http://localhost:8086}
|
||||
service-url: ${TOURNAMENT_SERVICE_URL:http://localhost:8088}
|
||||
|
||||
@@ -29,6 +29,7 @@ nowchess:
|
||||
secret: ${INTERNAL_SECRET:123abc}
|
||||
tournament:
|
||||
self-url: ""
|
||||
external-servers: ""
|
||||
|
||||
mp:
|
||||
jwt:
|
||||
@@ -51,6 +52,7 @@ mp:
|
||||
nowchess:
|
||||
tournament:
|
||||
self-url: ${TOURNAMENT_SELF_URL:}
|
||||
external-servers: ${TOURNAMENT_EXTERNAL_SERVERS:}
|
||||
|
||||
"%test":
|
||||
quarkus:
|
||||
|
||||
+13
-1
@@ -1,17 +1,29 @@
|
||||
package de.nowchess.tournament.service
|
||||
|
||||
import de.nowchess.tournament.dto.ExternalTournamentServer
|
||||
import jakarta.annotation.PostConstruct
|
||||
import jakarta.enterprise.context.ApplicationScoped
|
||||
import java.util.UUID
|
||||
import org.eclipse.microprofile.config.inject.ConfigProperty
|
||||
import java.util.{Optional, UUID}
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
import scala.jdk.CollectionConverters.*
|
||||
|
||||
@ApplicationScoped
|
||||
class TournamentServerRegistry:
|
||||
|
||||
@ConfigProperty(name = "nowchess.tournament.external-servers")
|
||||
var externalServers: Optional[String] = scala.compiletime.uninitialized
|
||||
|
||||
private val servers = new ConcurrentHashMap[String, ExternalTournamentServer]()
|
||||
private val tournaments = new ConcurrentHashMap[String, String]()
|
||||
|
||||
@PostConstruct
|
||||
def init(): Unit =
|
||||
if externalServers.isPresent then
|
||||
externalServers.get().split(",").map(_.trim).filter(_.nonEmpty).foreach { url =>
|
||||
register(url, url)
|
||||
}
|
||||
|
||||
def register(label: String, url: String): ExternalTournamentServer =
|
||||
val id = UUID.randomUUID().toString
|
||||
val server = ExternalTournamentServer(id, label, url.stripSuffix("/"))
|
||||
|
||||
Reference in New Issue
Block a user