chore: configurable delete retention interval (#10030)

Command line flag, as it also needs to be able to take effect during
migration.
This commit is contained in:
Jakob Borg
2025-04-03 09:55:19 +02:00
committed by GitHub
parent b88aea34b6
commit 8a2d8ebf81
5 changed files with 62 additions and 37 deletions
+14 -4
View File
@@ -17,10 +17,12 @@ import (
)
type DB struct {
sql *sqlx.DB
localDeviceIdx int64
updateLock sync.Mutex
updatePoints int
sql *sqlx.DB
localDeviceIdx int64
deleteRetention time.Duration
updateLock sync.Mutex
updatePoints int
statementsMut sync.RWMutex
statements map[string]*sqlx.Stmt
@@ -29,6 +31,14 @@ type DB struct {
var _ db.DB = (*DB)(nil)
type Option func(*DB)
func WithDeleteRetention(d time.Duration) Option {
return func(s *DB) {
s.deleteRetention = d
}
}
func (s *DB) Close() error {
s.updateLock.Lock()
s.statementsMut.Lock()