Organize store interfface
@@ -13,38 +13,86 @@ type Store interface {
AuthenticationStore
// Checks
+ CheckStore
+
+ // Entities
+ EntityStore
+
+ // Events
+ EventStore
+
+ // Handlers
+ HandlerStore
+
+ // Mutators
+ MutatorStore
+
+ // Users
+ UserStore
+
+ // Keepalives
+ KeepaliveStore
+}
+
+// AssetStore manage assets
+type AssetStore interface {
+ GetAssets() ([]*types.Asset, error)
+ GetAssetByName(assetName string) (*types.Asset, error)
+ UpdateAsset(asset *types.Asset) error
+ DeleteAssetByName(assetName string) error
+}
+
+// AuthenticationStore is responsible for managing the authentication state
+type AuthenticationStore interface {
+ CreateJWTSecret([]byte) error
+ GetJWTSecret() ([]byte, error)
+ UpdateJWTSecret([]byte) error
+}
+
+// CheckStore provides an interface for interacting & persisting checks
+type CheckStore interface {
GetChecks() ([]*types.Check, error)
GetCheckByName(name string) (*types.Check, error)
DeleteCheckByName(name string) error
UpdateCheck(check *types.Check) error
+}
- // Entities
+// EntityStore provides an interface for interacting & persisting entities
+type EntityStore interface {
GetEntityByID(id string) (*types.Entity, error)
UpdateEntity(e *types.Entity) error
DeleteEntity(e *types.Entity) error
DeleteEntityByID(id string) error
GetEntities() ([]*types.Entity, error)
+}
- // Events
+// EventStore provides an interface for interacting & persisting events
+type EventStore interface {
GetEvents() ([]*types.Event, error)
GetEventsByEntity(entityID string) ([]*types.Event, error)
GetEventByEntityCheck(entityID, checkID string) (*types.Event, error)
UpdateEvent(event *types.Event) error
DeleteEventByEntityCheck(entityID, checkID string) error
+}
- // Handlers
+// HandlerStore provides an interface for interacting & persisting handlers
+type HandlerStore interface {
GetHandlers() ([]*types.Handler, error)
GetHandlerByName(name string) (*types.Handler, error)
DeleteHandlerByName(name string) error
UpdateHandler(handler *types.Handler) error
+}
- // Mutators
+// MutatorStore provides an interface for interacting & persisting mutators
+type MutatorStore interface {
GetMutators() ([]*types.Mutator, error)
GetMutatorByName(name string) (*types.Mutator, error)
DeleteMutatorByName(name string) error
UpdateMutator(mutator *types.Mutator) error
+}
- // Users
+// UserStore provides an interface for interacting & persisting users
+type UserStore interface {
CreateUser(user *types.User) error
DeleteUserByName(username string) error
GetUser(username string) (*types.User, error)
@@ -52,23 +100,6 @@ type Store interface {
UpdateUser(user *types.User) error
}
-// AssetStore manage assets
-type AssetStore interface {
- GetAssets() ([]*types.Asset, error)
- GetAssetByName(assetName string) (*types.Asset, error)
- UpdateAsset(asset *types.Asset) error
- DeleteAssetByName(assetName string) error
-
- KeepaliveStore
-}
-
-// AuthenticationStore is responsible for managing the authentication state
-type AuthenticationStore interface {
- CreateJWTSecret([]byte) error
- GetJWTSecret() ([]byte, error)
- UpdateJWTSecret([]byte) error
-}
-
// KeepaliveStore is responsible for updating entity keepalive data.
type KeepaliveStore interface {
// UpdateKeepalive updates the current expiration time for an entity's
