From 63599c719d8e4e09548546bb366a849ef40c602b Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Sun, 9 Jun 2024 17:54:57 +0200 Subject: feat: add low-memory mode --- internal/config/config.go | 2 +- internal/config/default.go | 9 +++++---- internal/config/structs.go | 7 ++++--- 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'internal/config') diff --git a/internal/config/config.go b/internal/config/config.go index c8739f0..83ddd2c 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -91,7 +91,7 @@ func mustLocalTime(in string) (time LocalTime) { } func GetConfig(filename string) (*Config, error) { - config := defaultConfig + config := DefaultConfig if filename != "" { slog.Debug("reading config", "filename", filename) f, err := os.Open(filename) diff --git a/internal/config/default.go b/internal/config/default.go index 5e7b388..5b924a9 100644 --- a/internal/config/default.go +++ b/internal/config/default.go @@ -18,7 +18,7 @@ const self = "'self'" const maxAge = (1 * 365 * 24 * time.Hour) -var defaultConfig = Config{ +var DefaultConfig = Config{ DataPath: "./data", Web: &Web{ ListenAddress: "localhost", @@ -47,8 +47,9 @@ var defaultConfig = Config{ }, }, Importer: &Importer{ - Timeout: Duration{30 * time.Minute}, - UpdateAt: mustLocalTime("04:00:00"), + LowMemory: false, + Timeout: Duration{30 * time.Minute}, + UpdateAt: mustLocalTime("04:00:00"), Sources: map[string]*Source{ "nixos": { Name: "NixOS", @@ -116,7 +117,7 @@ var defaultConfig = Config{ } func GetDefaultConfig() string { - out, err := toml.Marshal(&defaultConfig) + out, err := toml.Marshal(&DefaultConfig) if err != nil { panic("could not read default configuration") } diff --git a/internal/config/structs.go b/internal/config/structs.go index a434698..70283f2 100644 --- a/internal/config/structs.go +++ b/internal/config/structs.go @@ -27,9 +27,10 @@ type Web struct { } type Importer struct { - Sources map[string]*Source - Timeout Duration `comment:"Abort fetch and import process for all jobs if it takes longer than this value."` - UpdateAt LocalTime `comment:"Local time of day to run fetch/import process"` + Sources map[string]*Source + LowMemory bool `comment:"Use less memory at the expense of import performance"` + Timeout Duration `comment:"Abort fetch and import process for all jobs if it takes longer than this value."` + UpdateAt LocalTime `comment:"Local time of day to run fetch/import process"` } type Source struct { -- cgit 1.4.1