From 5fe6165373951f9d454f2c88e597f679db22a37e Mon Sep 17 00:00:00 2001 From: Jim Martens Date: Thu, 17 Aug 2023 00:35:50 +0200 Subject: [PATCH] Remove property reload service --- .../service/PropertyReloadService.kt | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 module-server/src/main/kotlin/de/twomartens/wahlrecht/service/PropertyReloadService.kt diff --git a/module-server/src/main/kotlin/de/twomartens/wahlrecht/service/PropertyReloadService.kt b/module-server/src/main/kotlin/de/twomartens/wahlrecht/service/PropertyReloadService.kt deleted file mode 100644 index 54adffa..0000000 --- a/module-server/src/main/kotlin/de/twomartens/wahlrecht/service/PropertyReloadService.kt +++ /dev/null @@ -1,41 +0,0 @@ -package de.twomartens.wahlrecht.service - -import mu.KotlinLogging -import org.apache.logging.log4j.message.StringMapMessage -import org.springframework.beans.factory.annotation.Qualifier -import org.springframework.cloud.context.refresh.ContextRefresher -import org.springframework.scheduling.annotation.Scheduled -import org.springframework.stereotype.Service -import java.util.concurrent.TimeUnit - -/** - * automatically reloads application*.yaml. reload can also be triggered manually by doing a post - * request on http://localhost:12001/actuator/refresh - */ -@Service -class PropertyReloadService(@Qualifier("configDataContextRefresher") private val contextRefresher: ContextRefresher) { - @Scheduled( - fixedDelay = REFRESH_SECONDS.toLong(), - initialDelay = REFRESH_SECONDS.toLong(), - timeUnit = TimeUnit.SECONDS - ) - fun refresh() { - val properties = contextRefresher.refresh() - if (properties.isNotEmpty()) { - log.info( - StringMapMessage() - .with(PARAM_MESSAGE, "properties changed") - .with(PARAM_PROPERTIES, properties.joinToString("\n")) - .asString() - ) - } - } - - companion object { - const val REFRESH_SECONDS = 60 - const val PARAM_MESSAGE = "message" - const val PARAM_PROPERTIES = "labels.properties" - - private val log = KotlinLogging.logger {} - } -}