refactor: 30-day defaults for all expiry settings
All checks were successful
check / check (push) Successful in 2m20s
All checks were successful
check / check (push) Successful in 2m20s
- QUEUE_MAX_AGE: 48h -> 30 days (per-client queue entry expiry) - MESSAGE_MAX_AGE: replaces count-based MAX_HISTORY with time-based 30-day message expiry - SESSION_IDLE_TIMEOUT: 24h -> 30 days All expiry is now time-based (30 days) as requested. Closes #40
This commit is contained in:
@@ -31,7 +31,7 @@ type Params struct {
|
||||
Healthcheck *healthcheck.Healthcheck
|
||||
}
|
||||
|
||||
const defaultIdleTimeout = 24 * time.Hour
|
||||
const defaultIdleTimeout = 30 * 24 * time.Hour
|
||||
|
||||
// Handlers manages HTTP request handling.
|
||||
type Handlers struct {
|
||||
@@ -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 prunes 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