refactor: 30-day defaults, time-based message expiry
All checks were successful
check / check (push) Successful in 5s
All checks were successful
check / check (push) Successful in 5s
- Change QUEUE_MAX_AGE default from 48h to 30 days (2592000s) - Replace count-based MAX_HISTORY with time-based MESSAGE_MAX_AGE (default 30 days) — messages older than the configured age are pruned instead of keeping a fixed count per target - Update README to reflect new defaults and time-based expiry
This commit is contained in:
@@ -205,8 +205,7 @@ func (hdlr *Handlers) runCleanup(
|
||||
}
|
||||
|
||||
// pruneQueuesAndMessages removes old client_queues entries
|
||||
// per QUEUE_MAX_AGE, rotates messages per MAX_HISTORY, and
|
||||
// cleans up orphaned messages.
|
||||
// per QUEUE_MAX_AGE and old messages per MESSAGE_MAX_AGE.
|
||||
func (hdlr *Handlers) pruneQueuesAndMessages(
|
||||
ctx context.Context,
|
||||
) {
|
||||
@@ -230,18 +229,22 @@ func (hdlr *Handlers) pruneQueuesAndMessages(
|
||||
}
|
||||
}
|
||||
|
||||
maxHistory := hdlr.params.Config.MaxHistory
|
||||
if maxHistory > 0 {
|
||||
rotated, err := hdlr.params.Database.
|
||||
RotateChannelMessages(ctx, maxHistory)
|
||||
messageMaxAge := hdlr.params.Config.MessageMaxAge
|
||||
if messageMaxAge > 0 {
|
||||
msgCutoff := time.Now().Add(
|
||||
-time.Duration(messageMaxAge) * time.Second,
|
||||
)
|
||||
|
||||
pruned, err := hdlr.params.Database.
|
||||
PruneOldMessages(ctx, msgCutoff)
|
||||
if err != nil {
|
||||
hdlr.log.Error(
|
||||
"message rotation failed", "error", err,
|
||||
"message pruning failed", "error", err,
|
||||
)
|
||||
} else if rotated > 0 {
|
||||
} else if pruned > 0 {
|
||||
hdlr.log.Info(
|
||||
"rotated old messages",
|
||||
"deleted", rotated,
|
||||
"pruned old messages",
|
||||
"deleted", pruned,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user