Repository navigation
feat: configurable per-application message retention period - #1063
Closed
carlosalbertorg wants to merge 1 commit into
Closed
carlosalbertorg wants to merge 1 commit into
carlosalbertorg wants to merge 1 commit into
Conversation
Applications now have a RetentionSeconds field (0 = use the server's default). A new GOTIFY_MESSAGERETENTIONSECONDS env var sets that server-wide default for applications that don't override it. A background goroutine prunes expired messages every minute. This follows the spec from gotify#376: "Each application should get a separate setting for the retention period. The pruning should be done in a separate goroutine that executes an sql query every minute to prune messages outside of the retention period. The default retention period should be unlimited." Closes gotify#376
Member
|
Thanks for the contribution. As said in my last comment, I've already started working on this, with the implementation as described in here #376 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #376.
What this does
Applicationgets aRetentionSecondsfield (0 = use the server's default, mirrors the existingClient.ExpiresAfterInactivitySecondspattern).GOTIFY_MESSAGERETENTIONSECONDSenv var sets the server-wide default for applications that don't set their own retention period (also 0 = unlimited, i.e. today's behavior is preserved with no config change).router.go) callsPruneMessagesevery minute, deleting messages older than the applicable retention period.This is exactly the spec from the issue:
Scope note
Later comments on the issue discussed a richer hierarchy (a hard global max, a separate global default, per-message overrides, etc.). I deliberately did not build that - it was never fully settled even among commenters, and this codebase has no existing pattern for a runtime-editable global setting (everything global is env-var/startup config, e.g.
config/config.go). Happy to extend this if a global default isn't enough and a hard max is also wanted - figured it's better to ship the agreed-upon core first.Testing
DatabaseSuite.TestPruneMessages(per-app override, global default, and "both zero = unlimited" cases, plus a boundary check at the exact cutoff).Test_UpdateApplicationRetentionSeconds_expectSuccessin the API suite.Test_ensureApplicationHasCorrectJsonRepresentationfor the new JSON field.application.test.tscolumn indices (the new UI column shifted them).go test ./...,golangci-lint run, and the fulluiyarn lint/format/build/test all pass locally (only the Docker-dependent OIDC/dex tests don't run in my environment - unrelated, pre-existing).docs/spec.jsonregenerated viaswagger generate spec.