feat: Health-Check-Ports und Service-URLs konsolidiert, Consul-Best-Practices umgesetzt

Signed-off-by: StefanMoCoAt <stefan.mo.co@gmail.com>
This commit is contained in:
2026-04-16 21:26:54 +02:00
parent dd76ad6d14
commit 26b3b193ca
19 changed files with 130 additions and 43 deletions
@@ -1,6 +1,5 @@
package at.mocode.infrastructure.gateway.config
import org.springframework.beans.factory.annotation.Value
import org.springframework.cloud.gateway.route.RouteLocator
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder
import org.springframework.cloud.gateway.route.builder.filters
@@ -9,15 +8,7 @@ import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
@Configuration
class GatewayConfig(
@Value("\${ping.service.url:http://localhost:8082}") private val pingServiceUrl: String,
@Value("\${masterdata.service.url:http://localhost:8086}") private val masterdataServiceUrl: String,
@Value("\${events.service.url:http://localhost:8085}") private val eventsServiceUrl: String,
@Value("\${zns.import.service.url:http://localhost:8095}") private val znsImportServiceUrl: String,
@Value("\${results.service.url:http://localhost:8088}") private val resultsServiceUrl: String,
@Value("\${series.service.url:http://localhost:8089}") private val seriesServiceUrl: String,
@Value("\${billing.service.url:http://localhost:8087}") private val billingServiceUrl: String
) {
class GatewayConfig {
@Bean
fun customRouteLocator(builder: RouteLocatorBuilder): RouteLocator {
@@ -31,31 +22,31 @@ class GatewayConfig(
it.fallbackUri = java.net.URI.create("forward:/fallback/ping")
}
}
uri(pingServiceUrl)
uri("lb://ping-service")
}
route(id = "masterdata-service") {
path("/api/v1/masterdata/**")
uri(masterdataServiceUrl)
uri("lb://masterdata-service")
}
route(id = "events-service") {
path("/api/v1/events/**")
uri(eventsServiceUrl)
uri("lb://events-service")
}
route(id = "zns-import-service") {
path("/api/v1/import/zns/**", "/api/v1/import/zns")
uri(znsImportServiceUrl)
uri("lb://zns-import-service")
}
route(id = "results-service") {
path("/api/v1/results/**")
uri(resultsServiceUrl)
uri("lb://results-service")
}
route(id = "series-service") {
path("/api/v1/series/**")
uri(seriesServiceUrl)
uri("lb://series-service")
}
route(id = "billing-service") {
path("/api/v1/billing/**")
uri(billingServiceUrl)
uri("lb://billing-service")
}
}
}
@@ -25,13 +25,13 @@ spring:
prefer-ip-address: true
health-check-path: /actuator/health
health-check-interval: 10s
health-check-port: ${server.port}
health-check-port: 8081
instance-id: ${spring.application.name}:${server.port}:${random.uuid}
service-name: ${spring.application.name}
gateway:
httpclient: { }
# Routen sind in GatewayConfig.kt definiert
# Routen sind in GatewayConfig.kt via Service-Discovery (lb://) definiert
# --- SECURITY (OAuth2 Resource Server) ---
security:
@@ -66,9 +66,3 @@ management:
# Lokal: Zipkin auf Port 9411. In Docker via ENV MANAGEMENT_ZIPKIN_TRACING_ENDPOINT überschrieben.
endpoint: ${MANAGEMENT_ZIPKIN_TRACING_ENDPOINT:http://localhost:9411/api/v2/spans}
# --- Custom Service URLs ---
# Default: Localhost (für Entwicklung ohne Docker)
# Im Docker-Compose überschreiben wir das mit dem Service-Namen
ping:
service:
url: ${PING_SERVICE_URL:http://localhost:8082}