Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cleanUpWorkerEnabled flag to control clean up worker execution #21

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading