From a89a268725a47a17aa54face80448cc0c491d346 Mon Sep 17 00:00:00 2001 From: NovaFox161 Date: Fri, 15 Mar 2024 11:16:32 -0500 Subject: [PATCH] Make static message update task frequency configurable Also default it to every 30 minutes instead of every 60 --- .../client/business/cronjob/StaticMessageUpdateCronJob.kt | 4 +++- .../kotlin/org/dreamexposure/discal/core/config/Config.kt | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/main/kotlin/org/dreamexposure/discal/client/business/cronjob/StaticMessageUpdateCronJob.kt b/client/src/main/kotlin/org/dreamexposure/discal/client/business/cronjob/StaticMessageUpdateCronJob.kt index c4b600f2..0d9505da 100644 --- a/client/src/main/kotlin/org/dreamexposure/discal/client/business/cronjob/StaticMessageUpdateCronJob.kt +++ b/client/src/main/kotlin/org/dreamexposure/discal/client/business/cronjob/StaticMessageUpdateCronJob.kt @@ -5,6 +5,8 @@ import org.dreamexposure.discal.Application.Companion.getShardCount import org.dreamexposure.discal.Application.Companion.getShardIndex import org.dreamexposure.discal.core.business.MetricService import org.dreamexposure.discal.core.business.StaticMessageService +import org.dreamexposure.discal.core.config.Config +import org.dreamexposure.discal.core.extensions.asMinutes import org.dreamexposure.discal.core.logger.LOGGER import org.dreamexposure.discal.core.utils.GlobalVal.DEFAULT import org.springframework.boot.ApplicationArguments @@ -22,7 +24,7 @@ class StaticMessageUpdateCronJob( private val metricService: MetricService, ):ApplicationRunner { override fun run(args: ApplicationArguments?) { - Flux.interval(Duration.ofHours(1)) + Flux.interval(Config.TIMING_STATIC_MESSAGE_UPDATE_TASK_RUN_INTERVAL_MINUTES.getLong().asMinutes()) .onBackpressureDrop() .flatMap { doUpdate() } .onErrorResume { Mono.empty() } diff --git a/core/src/main/kotlin/org/dreamexposure/discal/core/config/Config.kt b/core/src/main/kotlin/org/dreamexposure/discal/core/config/Config.kt index e19e837a..2b90ea3f 100644 --- a/core/src/main/kotlin/org/dreamexposure/discal/core/config/Config.kt +++ b/core/src/main/kotlin/org/dreamexposure/discal/core/config/Config.kt @@ -36,6 +36,7 @@ enum class Config(private val key: String, private var value: Any? = null) { TIMING_BOT_STATUS_UPDATE_MINUTES("bot.timing.status-update.minutes", 5), TIMING_ANNOUNCEMENT_TASK_RUN_INTERVAL_MINUTES("bot.timing.announcement.task-run-interval.minutes", 5), TIMING_WIZARD_TIMEOUT_MINUTES("bot.timing.wizard-timeout.minutes", 30), + TIMING_STATIC_MESSAGE_UPDATE_TASK_RUN_INTERVAL_MINUTES("bot.timing.static-message.update.task-run-interval.minutes", 30), // Bot secrets SECRET_DISCAL_API_KEY("bot.secret.api-token"),