Add logs retention#38
Merged
Merged
Conversation
- Add retention parameter to config (seconds) - Add DeleteOlderThan method to RequestLogService - Start scheduler to cleanup old logs when retention is configured - Run cleanup every hour to avoid excessive DB load - Add context cancellation for graceful shutdown - Add test for DeleteOlderThan functionality
Fixes P2 finding from code review: DELETE queries on time column would perform full table scans without an index. Also fixes SQLite locking issue by closing PRAGMA query rows explicitly before DDL.
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 #21
Summary
Adds a
retentionparameter to config that enables automatic cleanup of old request logs from the database.Changes
internal/config/config.go): AddedRetentionfield (int, seconds)internal/requestlog/service.go): AddedDeleteOlderThan(thresholdUnix int64)methodinternal/app/build.go):retention > 0cleanupIntervalconstant)internal/requestlog/handler_test.go): Added test forDeleteOlderThanfunctionalityBehavior
retentionis not set or 0, no cleanup occurs (existing behavior)retentionis set to N seconds, logs older than N seconds are deleted every hourTesting
TestDeleteOlderThan_RemovesOnlyOldLogsverifies correct deletion behaviorCode Review
Addressed P2 findings from code review: