feat: Make maximum number of results and events configurable (#1110)

This commit is contained in:
TwiN authored and GitHub committed 2025-05-17 16:10:28 -04:00
1 parent c411b001eb
commit 04692d15ba
29 files changed
+231 -161

No files matched your search

+6 -3
View File
@@ -111,7 +111,10 @@ func Initialize(cfg *storage.Config) error {
if cfg == nil {
// This only happens in tests
logr.Warn("[store.Initialize] nil storage config passed as parameter. This should only happen in tests. Defaulting to an empty config.")
cfg = &storage.Config{}
cfg = &storage.Config{
MaximumNumberOfResults: storage.DefaultMaximumNumberOfResults,
MaximumNumberOfEvents: storage.DefaultMaximumNumberOfEvents,
}
}
if len(cfg.Path) == 0 && cfg.Type != storage.TypePostgres {
logr.Infof("[store.Initialize] Creating storage provider of type=%s", cfg.Type)
@@ -119,14 +122,14 @@ func Initialize(cfg *storage.Config) error {
ctx, cancelFunc = context.WithCancel(context.Background())
switch cfg.Type {
case storage.TypeSQLite, storage.TypePostgres:
store, err = sql.NewStore(string(cfg.Type), cfg.Path, cfg.Caching)
store, err = sql.NewStore(string(cfg.Type), cfg.Path, cfg.Caching, cfg.MaximumNumberOfResults, cfg.MaximumNumberOfEvents)
if err != nil {
return err
}
case storage.TypeMemory:
fallthrough
default:
store, _ = memory.NewStore()
store, _ = memory.NewStore(cfg.MaximumNumberOfResults, cfg.MaximumNumberOfEvents)
}
return nil
}