Close #124: Add support for Postgres as a storage solution

This commit is contained in:
TwinProduction
2021-09-10 18:00:04 -04:00
committed by Chris
parent 06ef7f9efe
commit bacf7d841b
47 changed files with 7593 additions and 244 deletions

View File

@ -6,20 +6,20 @@ import (
"github.com/TwinProduction/gatus/core"
"github.com/TwinProduction/gatus/storage/store/common/paging"
"github.com/TwinProduction/gatus/storage/store/memory"
"github.com/TwinProduction/gatus/storage/store/sqlite"
"github.com/TwinProduction/gatus/storage/store/sql"
)
// Store is the interface that each stores should implement
type Store interface {
// GetAllServiceStatuses returns the JSON encoding of all monitored core.ServiceStatus
// with a subset of core.Result defined by the page and pageSize parameters
GetAllServiceStatuses(params *paging.ServiceStatusParams) []*core.ServiceStatus
GetAllServiceStatuses(params *paging.ServiceStatusParams) ([]*core.ServiceStatus, error)
// GetServiceStatus returns the service status for a given service name in the given group
GetServiceStatus(groupName, serviceName string, params *paging.ServiceStatusParams) *core.ServiceStatus
GetServiceStatus(groupName, serviceName string, params *paging.ServiceStatusParams) (*core.ServiceStatus, error)
// GetServiceStatusByKey returns the service status for a given key
GetServiceStatusByKey(key string, params *paging.ServiceStatusParams) *core.ServiceStatus
GetServiceStatusByKey(key string, params *paging.ServiceStatusParams) (*core.ServiceStatus, error)
// GetUptimeByKey returns the uptime percentage during a time range
GetUptimeByKey(key string, from, to time.Time) (float64, error)
@ -31,7 +31,7 @@ type Store interface {
GetHourlyAverageResponseTimeByKey(key string, from, to time.Time) (map[int64]int, error)
// Insert adds the observed result for the specified service into the store
Insert(service *core.Service, result *core.Result)
Insert(service *core.Service, result *core.Result) error
// DeleteAllServiceStatusesNotInKeys removes all ServiceStatus that are not within the keys provided
//
@ -44,7 +44,7 @@ type Store interface {
// Save persists the data if and where it needs to be persisted
Save() error
// Close terminates every connections and closes the store, if applicable.
// Close terminates every connection and closes the store, if applicable.
// Should only be used before stopping the application.
Close()
}
@ -54,5 +54,5 @@ type Store interface {
var (
// Validate interface implementation on compile
_ Store = (*memory.Store)(nil)
_ Store = (*sqlite.Store)(nil)
_ Store = (*sql.Store)(nil)
)