storage

package
v0.0.0-...-205cd9e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 19, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockStorage

type MockStorage struct {
	// contains filtered or unexported fields
}

MockStorage is the mock implementation of the MongoStorage struct

func NewMockStorage

func NewMockStorage() *MockStorage

NewMockStorage initalizes and returns new MockStorage instance

func (*MockStorage) CountProcessAlertLogs

func (m *MockStorage) CountProcessAlertLogs() (int, error)

CountProcessAlertLogs .

func (*MockStorage) CreateAlert

func (m *MockStorage) CreateAlert(alert *models.Alert) error

CreateAlert .

func (*MockStorage) CreateUser

func (m *MockStorage) CreateUser(user *models.User) error

CreateUser .

func (*MockStorage) GetAlert

func (m *MockStorage) GetAlert(alertID string) (*models.Alert, error)

GetAlert .

func (*MockStorage) GetAlertHistory

func (m *MockStorage) GetAlertHistory(alertID string, limit int) ([]*models.ProcessAlert, error)

GetAlertHistory .

func (*MockStorage) GetUserAlerts

func (m *MockStorage) GetUserAlerts(userID string) ([]*models.Alert, error)

GetUserAlerts .

func (*MockStorage) LogCreateAlert

func (m *MockStorage) LogCreateAlert(alert *models.Alert) error

LogCreateAlert .

func (*MockStorage) LogCreateUser

func (m *MockStorage) LogCreateUser(alert *models.User) error

LogCreateUser .

func (*MockStorage) LogProcessAlert

func (m *MockStorage) LogProcessAlert(alert *models.Alert, statusCode int) error

LogProcessAlert .

func (*MockStorage) UpdateAlert

func (m *MockStorage) UpdateAlert(alert *models.Alert) error

UpdateAlert .

type MongoStorage

type MongoStorage struct {
	// contains filtered or unexported fields
}

MongoStorage struct is used for storeing persistant data of alerts

func NewStorage

func NewStorage(url config.MongoConfig) *MongoStorage

NewStorage creates and returns new Storage instance

func (*MongoStorage) CountProcessAlertLogs

func (s *MongoStorage) CountProcessAlertLogs() (int, error)

CountProcessAlertLogs counts total number of "process_alert" events

func (*MongoStorage) CreateAlert

func (s *MongoStorage) CreateAlert(a *models.Alert) error

CreateAlert adds new alert to storage

func (*MongoStorage) CreateUser

func (s *MongoStorage) CreateUser(user *models.User) error

CreateUser creates new user

func (*MongoStorage) GetAlert

func (s *MongoStorage) GetAlert(alertID string) (*models.Alert, error)

GetAlert Finds and returns alert data from storage

func (*MongoStorage) GetAlertHistory

func (s *MongoStorage) GetAlertHistory(alertID string, limit int) ([]*models.ProcessAlert, error)

GetAlertHistory returns event history for passed alertID

func (*MongoStorage) GetDBSession

func (s *MongoStorage) GetDBSession() *mgo.Session

GetDBSession returns a new connection from the pool

func (*MongoStorage) GetUserAlerts

func (s *MongoStorage) GetUserAlerts(userID string) ([]*models.Alert, error)

GetUserAlerts .

func (*MongoStorage) LogCreateAlert

func (s *MongoStorage) LogCreateAlert(alert *models.Alert) error

LogCreateAlert creates create_alert event

func (*MongoStorage) LogCreateUser

func (s *MongoStorage) LogCreateUser(user *models.User) error

LogCreateUser creates create_user event

func (*MongoStorage) LogProcessAlert

func (s *MongoStorage) LogProcessAlert(alert *models.Alert, statusCode int) error

LogProcessAlert creates process_alert event

func (*MongoStorage) UpdateAlert

func (s *MongoStorage) UpdateAlert(alert *models.Alert) error

UpdateAlert .

type Storage

type Storage interface {
	CreateUser(*models.User) error
	CreateAlert(*models.Alert) error
	GetAlert(string) (*models.Alert, error)
	UpdateAlert(*models.Alert) error
	GetUserAlerts(string) ([]*models.Alert, error)
	GetAlertHistory(string, int) ([]*models.ProcessAlert, error)
	CountProcessAlertLogs() (int, error)
	LogProcessAlert(*models.Alert, int) error
	LogCreateAlert(*models.Alert) error
	LogCreateUser(*models.User) error
}

Storage .

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL