Files
job-search/internal/config/conf_database.go
T
bwilliams 65e5bc6b26 Added database.change_batch_retention, deleting old change batches
Each save that records a batch also deletes, in the same
transaction, the batches older than database.change_batch_retention
(30 days by default; 0 or less keeps them for ever), with their
records of opportunities. A client still holding a deleted batch
gets 410 Gone from ?changed_after= and reloads the whole list, as
for any unknown batch.
2026-10-16 16:10:32 +01:00

48 lines
1.4 KiB
Go

package config
import (
"reflect"
"time"
)
// JSCKDatabase is the database section's configuration key.
const JSCKDatabase string = "database"
// JSCDatabase configures the SQLite database. File is the path to
// the database file; empty means none, and commands that need the database
// fail with a message saying so. ChangeBatchRetention is how long a batch of
// changed opportunities is kept for clients to catch up from (see
// store.WithChangeBatchRetention); 0 or less means they are kept for ever.
type JSCDatabase struct {
File string `cfg:"file"`
ChangeBatchRetention time.Duration `cfg:"change_batch_retention" default:"720h"`
}
// ---------- Section methods (see Section) ----------
// Keys returns the keys directly in the section.
func (c *JSCDatabase) Keys() []string { return keysOf(c) }
// Map implements Section.
func (c JSCDatabase) Map() map[string]any { return mapOf(c) }
// Flatten implements Section.
func (c JSCDatabase) Flatten() map[string]any {
return flattenOf(JSCKDatabase, c)
}
// TypeOf implements Section.
func (c JSCDatabase) TypeOf(key string) (reflect.Kind, error) {
return typeOf(c, key)
}
// ValueOf implements Section.
func (c JSCDatabase) ValueOf(key string) (any, error) {
return valueOf(c, key)
}
// SetValue implements Section.
func (c *JSCDatabase) SetValue(key string, value any) error {
return setValue(c, key, value)
}