mirror of
https://github.com/TwiN/gatus.git
synced 2026-02-15 17:55:05 +00:00
feat: Make maximum number of results and events configurable (#1110)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user