diff --git a/modules/official-bots/src/main/resources/application.yml b/modules/official-bots/src/main/resources/application.yml index 7de45ca..e1a27b4 100644 --- a/modules/official-bots/src/main/resources/application.yml +++ b/modules/official-bots/src/main/resources/application.yml @@ -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} diff --git a/modules/tournament/src/main/resources/application.yml b/modules/tournament/src/main/resources/application.yml index ca5e1cf..7ce7122 100644 --- a/modules/tournament/src/main/resources/application.yml +++ b/modules/tournament/src/main/resources/application.yml @@ -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: diff --git a/modules/tournament/src/main/scala/de/nowchess/tournament/service/TournamentServerRegistry.scala b/modules/tournament/src/main/scala/de/nowchess/tournament/service/TournamentServerRegistry.scala index 6f9d02e..0b12342 100644 --- a/modules/tournament/src/main/scala/de/nowchess/tournament/service/TournamentServerRegistry.scala +++ b/modules/tournament/src/main/scala/de/nowchess/tournament/service/TournamentServerRegistry.scala @@ -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("/"))