2021-02-03 05:06:34 +01:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/TwinProduction/gatus/core"
|
2021-07-12 06:56:30 +02:00
|
|
|
"github.com/TwinProduction/gatus/storage/store/database"
|
2021-02-03 05:06:34 +01:00
|
|
|
"github.com/TwinProduction/gatus/storage/store/memory"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Store is the interface that each stores should implement
|
|
|
|
type Store interface {
|
2021-05-19 07:19:02 +02:00
|
|
|
// GetAllServiceStatusesWithResultPagination returns the JSON encoding of all monitored core.ServiceStatus
|
2021-02-25 04:41:36 +01:00
|
|
|
// with a subset of core.Result defined by the page and pageSize parameters
|
|
|
|
GetAllServiceStatusesWithResultPagination(page, pageSize int) map[string]*core.ServiceStatus
|
2021-02-03 05:06:34 +01:00
|
|
|
|
|
|
|
// GetServiceStatus returns the service status for a given service name in the given group
|
|
|
|
GetServiceStatus(groupName, serviceName string) *core.ServiceStatus
|
|
|
|
|
|
|
|
// GetServiceStatusByKey returns the service status for a given key
|
|
|
|
GetServiceStatusByKey(key string) *core.ServiceStatus
|
|
|
|
|
|
|
|
// Insert adds the observed result for the specified service into the store
|
|
|
|
Insert(service *core.Service, result *core.Result)
|
|
|
|
|
|
|
|
// DeleteAllServiceStatusesNotInKeys removes all ServiceStatus that are not within the keys provided
|
|
|
|
//
|
|
|
|
// Used to delete services that have been persisted but are no longer part of the configured services
|
|
|
|
DeleteAllServiceStatusesNotInKeys(keys []string) int
|
|
|
|
|
|
|
|
// Clear deletes everything from the store
|
|
|
|
Clear()
|
2021-02-06 02:45:28 +01:00
|
|
|
|
|
|
|
// Save persists the data if and where it needs to be persisted
|
|
|
|
Save() error
|
2021-02-03 05:06:34 +01:00
|
|
|
}
|
|
|
|
|
2021-07-13 04:53:14 +02:00
|
|
|
// TODO: add method to check state of store (by keeping track of silent errors)
|
|
|
|
|
2021-02-03 05:06:34 +01:00
|
|
|
var (
|
|
|
|
// Validate interface implementation on compile
|
|
|
|
_ Store = (*memory.Store)(nil)
|
2021-07-12 06:56:30 +02:00
|
|
|
_ Store = (*database.Store)(nil)
|
2021-02-03 05:06:34 +01:00
|
|
|
)
|