Compare commits

..
13 Commits
Author SHA1 Message Date
2martens 56c6fef178 Remove constructor binding
continuous-integration/drone/push Build is failing
2023-08-17 02:02:19 +02:00
2martens 46b1b32708 Properties must be changeable with setters
continuous-integration/drone/push Build is failing
2023-08-17 01:52:50 +02:00
2martens 519101023c Change message [CI SKIP] 2023-08-17 01:42:01 +02:00
2martens 82b4f51390 Require configserver on prod
continuous-integration/drone/push Build is failing
2023-08-17 01:38:26 +02:00
2martens 3256939ac7 Change message [CI SKIP] 2023-08-17 01:20:17 +02:00
2martens 02e4c5318d Fix bootstrap servers on prod
continuous-integration/drone/push Build is failing
2023-08-17 01:14:03 +02:00
2martens f06abd2838 Add application name
continuous-integration/drone/push Build is failing
2023-08-17 01:12:38 +02:00
2martens f0297f2d2c Changed prod message [CI SKIP] 2023-08-17 01:10:11 +02:00
2martens ec23bd4d32 Connect with kafka using bootstrap servers
continuous-integration/drone/push Build is failing
2023-08-17 00:53:05 +02:00
2martens bab1892673 Added kafka server config
continuous-integration/drone/push Build is failing
2023-08-17 00:42:53 +02:00
2martens 247fe83caa Changed config [CI SKIP] 2023-08-17 00:36:27 +02:00
2martens 5fe6165373 Remove property reload service
continuous-integration/drone/push Build is failing
2023-08-17 00:35:50 +02:00
2martens 64a8f17e6e Change greeting on dev [CI SKIP] 2023-08-17 00:04:56 +02:00
7 changed files with 11 additions and 47 deletions
@@ -1,6 +1,7 @@
package de.twomartens.wahlrecht.configuration package de.twomartens.wahlrecht.configuration
import de.twomartens.wahlrecht.property.ServiceProperties import de.twomartens.wahlrecht.property.ServiceProperties
import org.springframework.cloud.context.config.annotation.RefreshScope
import org.springframework.context.annotation.Bean import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration import org.springframework.context.annotation.Configuration
import java.time.Clock import java.time.Clock
@@ -9,6 +10,7 @@ import java.time.Clock
open class ClockConfiguration(private val serviceProperties: ServiceProperties) { open class ClockConfiguration(private val serviceProperties: ServiceProperties) {
@Bean @Bean
@RefreshScope
open fun clock(): Clock { open fun clock(): Clock {
return Clock.system(serviceProperties.defaultTimeZone) return Clock.system(serviceProperties.defaultTimeZone)
} }
@@ -2,11 +2,10 @@ package de.twomartens.wahlrecht.property
import io.swagger.v3.oas.annotations.media.Schema import io.swagger.v3.oas.annotations.media.Schema
import org.springframework.boot.context.properties.ConfigurationProperties import org.springframework.boot.context.properties.ConfigurationProperties
import org.springframework.boot.context.properties.bind.ConstructorBinding
import org.springframework.cloud.context.config.annotation.RefreshScope import org.springframework.cloud.context.config.annotation.RefreshScope
import java.time.ZoneId import java.time.ZoneId
@RefreshScope @RefreshScope
@ConfigurationProperties(prefix = "de.twomartens.wahlrecht") @ConfigurationProperties(prefix = "de.twomartens.wahlrecht")
@Schema(description = "Properties, to configure this Application") @Schema(description = "Properties, to configure this Application")
data class ServiceProperties @ConstructorBinding constructor(val defaultTimeZone: ZoneId, val greeting: String) data class ServiceProperties(var defaultTimeZone: ZoneId, var greeting: String)
@@ -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 {}
}
}
@@ -1,5 +1,7 @@
spring: spring:
config: config:
import: import:
- "classpath:config/wahlrecht.yaml" - "configserver:http://configserver:8888/config"
- "optional:configserver:http://configserver:8888/config" kafka:
bootstrap-servers:
- kafka:9092
@@ -38,6 +38,8 @@ spring:
resourceserver: resourceserver:
jwt: jwt:
jwk-set-uri: https://id.2martens.de/realms/2martens/protocol/openid-connect/certs jwk-set-uri: https://id.2martens.de/realms/2martens/protocol/openid-connect/certs
application:
name: wahlrecht
springdoc: springdoc:
swagger-ui: swagger-ui:
@@ -1,2 +1,2 @@
de.twomartens.wahlrecht: de.twomartens.wahlrecht:
greeting: "Moin %s, you are great" greeting: "Moin %s, you are stage"
@@ -1,6 +1,6 @@
de.twomartens.wahlrecht: de.twomartens.wahlrecht:
defaultTimeZone: Europe/Berlin defaultTimeZone: Europe/Berlin
greeting: "Hello %s" greeting: "Hello %s, on millenium"
statusprobe: statusprobe:
scheduleDuration: 60 scheduleDuration: 60
maxKafkaFailureDuration: 5 maxKafkaFailureDuration: 5