mirror of
https://github.com/TwiN/gatus.git
synced 2024-12-14 11:58:04 +00:00
Minor updates
This commit is contained in:
parent
f36b6863ce
commit
cfa2c8ef6f
3 changed files with 8 additions and 13 deletions
|
@ -6,8 +6,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrSQLStorageRequiresFile = errors.New("sql storage requires a non-empty file to be defined")
|
ErrSQLStorageRequiresPath = errors.New("sql storage requires a non-empty path to be defined")
|
||||||
ErrMemoryStorageDoesNotSupportFile = errors.New("memory storage does not support persistence, use sqlite if you want persistence on file")
|
ErrMemoryStorageDoesNotSupportPath = errors.New("memory storage does not support persistence, use sqlite if you want persistence on file")
|
||||||
ErrCannotSetBothFileAndPath = errors.New("file has been deprecated in favor of path: you cannot set both of them")
|
ErrCannotSetBothFileAndPath = errors.New("file has been deprecated in favor of path: you cannot set both of them")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ func (c *Config) ValidateAndSetDefaults() error {
|
||||||
c.Type = TypeMemory
|
c.Type = TypeMemory
|
||||||
}
|
}
|
||||||
if (c.Type == TypePostgres || c.Type == TypeSQLite) && len(c.Path) == 0 {
|
if (c.Type == TypePostgres || c.Type == TypeSQLite) && len(c.Path) == 0 {
|
||||||
return ErrSQLStorageRequiresFile
|
return ErrSQLStorageRequiresPath
|
||||||
}
|
}
|
||||||
if c.Type == TypeMemory && len(c.Path) > 0 {
|
if c.Type == TypeMemory && len(c.Path) > 0 {
|
||||||
log.Println("WARNING: Your configuration is using a storage of type memory with persistence, which has been deprecated")
|
log.Println("WARNING: Your configuration is using a storage of type memory with persistence, which has been deprecated")
|
||||||
|
@ -53,7 +53,7 @@ func (c *Config) ValidateAndSetDefaults() error {
|
||||||
log.Println("WARNING: If you want persistence, use 'storage.type: sqlite' instead of 'storage.type: memory'")
|
log.Println("WARNING: If you want persistence, use 'storage.type: sqlite' instead of 'storage.type: memory'")
|
||||||
log.Println("WARNING: See https://github.com/TwiN/gatus/issues/198")
|
log.Println("WARNING: See https://github.com/TwiN/gatus/issues/198")
|
||||||
// XXX: Uncomment the following line for v4.0.0
|
// XXX: Uncomment the following line for v4.0.0
|
||||||
//return ErrMemoryStorageDoesNotSupportFile
|
//return ErrMemoryStorageDoesNotSupportPath
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -493,12 +493,6 @@ func (s *Store) getEndpointStatusByKey(tx *sql.Tx, key string, parameters *pagin
|
||||||
log.Printf("[sql][getEndpointStatusByKey] Failed to retrieve results for key=%s: %s", key, err.Error())
|
log.Printf("[sql][getEndpointStatusByKey] Failed to retrieve results for key=%s: %s", key, err.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//if parameters.IncludeUptime {
|
|
||||||
// now := time.Now()
|
|
||||||
// endpointStatus.Uptime.LastHour, _, err = s.getEndpointUptime(tx, endpointID, now.Add(-time.Hour), now)
|
|
||||||
// endpointStatus.Uptime.LastTwentyFourHours, _, err = s.getEndpointUptime(tx, endpointID, now.Add(-24*time.Hour), now)
|
|
||||||
// endpointStatus.Uptime.LastSevenDays, _, err = s.getEndpointUptime(tx, endpointID, now.Add(-7*24*time.Hour), now)
|
|
||||||
//}
|
|
||||||
return endpointStatus, nil
|
return endpointStatus, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,7 @@ var (
|
||||||
|
|
||||||
func Get() Store {
|
func Get() Store {
|
||||||
if !initialized {
|
if !initialized {
|
||||||
|
// This only happens in tests
|
||||||
log.Println("[store][Get] Provider requested before it was initialized, automatically initializing")
|
log.Println("[store][Get] Provider requested before it was initialized, automatically initializing")
|
||||||
err := Initialize(nil)
|
err := Initialize(nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -92,12 +93,12 @@ func Initialize(cfg *storage.Config) error {
|
||||||
cancelFunc()
|
cancelFunc()
|
||||||
}
|
}
|
||||||
if cfg == nil {
|
if cfg == nil {
|
||||||
|
// This only happens in tests
|
||||||
|
log.Println("[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{}
|
||||||
}
|
}
|
||||||
if len(cfg.Path) == 0 && cfg.Type != storage.TypePostgres {
|
if len(cfg.Path) == 0 && cfg.Type != storage.TypePostgres {
|
||||||
log.Printf("[store][Initialize] Creating storage provider with type=%s and file=%s", cfg.Type, cfg.Path)
|
log.Printf("[store][Initialize] Creating storage provider of type=%s", cfg.Type)
|
||||||
} else {
|
|
||||||
log.Printf("[store][Initialize] Creating storage provider with type=%s", cfg.Type)
|
|
||||||
}
|
}
|
||||||
ctx, cancelFunc = context.WithCancel(context.Background())
|
ctx, cancelFunc = context.WithCancel(context.Background())
|
||||||
switch cfg.Type {
|
switch cfg.Type {
|
||||||
|
|
Loading…
Reference in a new issue