Skip to content

Commit

Permalink
Merge pull request #21 from nkly-wolt/add-flag-controlling-cleanup-wo…
Browse files Browse the repository at this point in the history
…rker

Add cleanUpWorkerEnabled flag to control clean up worker execution
  • Loading branch information
nkly-wolt authored Aug 26, 2024
2 parents 8eb4d86 + d250e9c commit 03a4d49
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ val IdempotencyPlugin =
pluginConfig.idempotentResponseRepository
?: throw IllegalArgumentException("IdempotentRequestRepository must be provided")

CleanUpWorker(
scope = pluginConfig.cleanUpWorkerScope,
jitter = pluginConfig.cleanUpWorkerJitter,
interval = pluginConfig.cleanUpWorkerInterval,
idempotentResponseRepository = responseRepository,
storedResponseTTL = pluginConfig.storedResponseTTL,
).start()
if (pluginConfig.cleanUpWorkerEnabled) {
CleanUpWorker(
scope = pluginConfig.cleanUpWorkerScope,
jitter = pluginConfig.cleanUpWorkerJitter,
interval = pluginConfig.cleanUpWorkerInterval,
idempotentResponseRepository = responseRepository,
storedResponseTTL = pluginConfig.storedResponseTTL,
).start()
}

val logger = KotlinLogging.logger {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ class PluginConfiguration {
HttpMethod.Patch,
)

/**
* Flag that controls execution of clean up worker.
* Clean up worker is enabled by default, but consider disabling it if your response repository can leverage a built-in expiration mechanism (e.g. Redis key expiration time).
*/
var cleanUpWorkerEnabled = true

/**
* The coroutine scope for the worker that cleans up expired responses.
*/
Expand Down

0 comments on commit 03a4d49

Please sign in to comment.