Skip to content

Commit

Permalink
Make static message update task frequency configurable
Browse files Browse the repository at this point in the history
Also default it to every 30 minutes instead of every 60
  • Loading branch information
NovaFox161 committed Mar 15, 2024
1 parent 20a99ec commit a89a268
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Expand Up @@ -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
Expand All @@ -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() }
Expand Down
Expand Up @@ -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"),
Expand Down

0 comments on commit a89a268

Please sign in to comment.