db

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package db encapsulates all interaction with Revere's backing database storage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func New

func New(conf DBJSONModel) (*DB, error)

New validates conf and connects to the database specified in conf.

func (*DB) Beginx

func (db *DB) Beginx() (*Tx, error)

func (*DB) Init

func (db *DB) Init() error

func (*DB) IsExistingLabel

func (db *DB) IsExistingLabel(id LabelID) (exists bool)

func (*DB) IsExistingMonitor

func (db *DB) IsExistingMonitor(id MonitorID) (exists bool)

func (*DB) IsExistingResource

func (db *DB) IsExistingResource(id ResourceID) (exists bool)

func (*DB) IsExistingSilence

func (db *DB) IsExistingSilence(id SilenceID) (exists bool)

func (*DB) LoadActiveSilencesForMonitor

func (db *DB) LoadActiveSilencesForMonitor(monitorID MonitorID) ([]Silence, error)

func (*DB) LoadLabel

func (db *DB) LoadLabel(id LabelID) (*Label, error)

func (*DB) LoadLabels

func (db *DB) LoadLabels() ([]*Label, error)

func (*DB) LoadLabelsForMonitor

func (db *DB) LoadLabelsForMonitor(id MonitorID) ([]*MonitorLabel, error)

func (*DB) LoadMonitor

func (db *DB) LoadMonitor(id MonitorID) (*Monitor, error)

func (*DB) LoadMonitorSilence

func (db *DB) LoadMonitorSilence(id SilenceID) (*MonitorSilence, error)

func (*DB) LoadMonitorSilences

func (db *DB) LoadMonitorSilences() ([]*MonitorSilence, error)

func (*DB) LoadMonitorVersionInfosUpdatedSince

func (db *DB) LoadMonitorVersionInfosUpdatedSince(t time.Time) ([]MonitorVersionInfo, error)

func (*DB) LoadMonitors

func (db *DB) LoadMonitors() ([]*Monitor, error)

func (*DB) LoadMonitorsForLabel

func (db *DB) LoadMonitorsForLabel(id LabelID) ([]LabelMonitor, error)

func (*DB) LoadProbeByMonitorID

func (db *DB) LoadProbeByMonitorID(id MonitorID) (types.JSONText, ProbeType, error)

func (*DB) LoadReadings

func (db *DB) LoadReadings(subprobeID SubprobeID) ([]*Reading, error)

func (*DB) LoadResources

func (db *DB) LoadResources() ([]*Resource, error)

func (*DB) LoadResourcesOfTypes

func (db *DB) LoadResourcesOfTypes(ids []ResourceType) ([]*Resource, error)

func (*DB) LoadSettingById

func (db *DB) LoadSettingById(id SettingID) (*Setting, error)

func (*DB) LoadSettings

func (db *DB) LoadSettings() (settings []*Setting, err error)

func (*DB) LoadSettingsOfType

func (db *DB) LoadSettingsOfType(settingType SettingType) (settings []*Setting, err error)

func (*DB) LoadSubprobe

func (db *DB) LoadSubprobe(subprobeID SubprobeID) (*Subprobe, error)

func (*DB) LoadSubprobeStatusesForMonitor

func (db *DB) LoadSubprobeStatusesForMonitor(id MonitorID) (map[string]SubprobeStatus, error)

func (*DB) LoadSubprobeWithStatusInfo

func (db *DB) LoadSubprobeWithStatusInfo(subprobeID SubprobeID) (*SubprobeWithStatusInfo, error)

func (*DB) LoadTriggersForLabel

func (db *DB) LoadTriggersForLabel(id LabelID) ([]LabelTrigger, error)

func (*DB) LoadTriggersForMonitor

func (db *DB) LoadTriggersForMonitor(id MonitorID) ([]MonitorTrigger, error)

func (*DB) Prefix

func (db *DB) Prefix() string

Prefix returns the prefix to add to table names in queries.

func (*DB) Tx

func (db *DB) Tx(f func(*Tx) error) (err error)

func (*DB) Unsafe

func (db *DB) Unsafe() *DB

type DBJSONModel

type DBJSONModel struct {
	DSN         string
	TablePrefix string
}

DBJSONModel provides the settings for a DB. It is used as the structure for configuring Revere's database connection in Revere's environment configuration JSON file.

type Label

type Label struct {
	LabelID     LabelID
	Name        string
	Description string
}

type LabelID

type LabelID int32

type LabelMonitor

type LabelMonitor struct {
	LabelID   LabelID
	Subprobes string
	*Monitor
}

type LabelTrigger

type LabelTrigger struct {
	LabelID LabelID
	*Trigger
}

type LabelTriggerWithSubprobes

type LabelTriggerWithSubprobes struct {
	LabelTrigger
	Subprobes string
}

type Monitor

type Monitor struct {
	MonitorID   MonitorID
	Name        string
	Owner       string
	Description string
	Response    string
	ProbeType   ProbeType
	Probe       types.JSONText
	Changed     time.Time
	Version     int32
	Archived    *time.Time
}

type MonitorID

type MonitorID int32

type MonitorLabel

type MonitorLabel struct {
	MonitorID MonitorID
	Subprobes string
	*Label
}

type MonitorSilence

type MonitorSilence struct {
	MonitorName string
	*Silence
}

type MonitorTrigger

type MonitorTrigger struct {
	MonitorID MonitorID
	Subprobes string
	*Trigger
}

type MonitorVersionInfo

type MonitorVersionInfo struct {
	MonitorID MonitorID
	Version   int32
	Archived  *time.Time
}

type ProbeType

type ProbeType int16

type Reading

type Reading struct {
	ReadingID  ReadingID
	SubprobeID SubprobeID
	Recorded   time.Time
	State      state.State
}

type ReadingID

type ReadingID int64

type Resource

type Resource struct {
	ResourceID   ResourceID
	ResourceType ResourceType
	Resource     string
}

type ResourceID

type ResourceID int32

type ResourceType

type ResourceType int16

type Setting

type Setting struct {
	SettingID   SettingID
	SettingType SettingType
	Setting     string
}

type SettingID

type SettingID int32

type SettingType

type SettingType int16

type Silence

type Silence struct {
	SilenceID SilenceID
	MonitorID MonitorID
	Subprobes string
	Start     time.Time
	End       time.Time
}

type SilenceID

type SilenceID int32

type Subprobe

type Subprobe struct {
	SubprobeID SubprobeID
	MonitorID  MonitorID
	Name       string
	Archived   *time.Time
}

type SubprobeID

type SubprobeID int32

type SubprobeStatus

type SubprobeStatus struct {
	SubprobeID   SubprobeID
	Recorded     time.Time
	State        state.State
	Silenced     bool
	EnteredState time.Time
	LastNormal   time.Time
}

type SubprobeWithStatusInfo

type SubprobeWithStatusInfo struct {
	MonitorID   MonitorID
	MonitorName string
	Name        string
	Archived    *time.Time
	*SubprobeStatus
}

type TargetType

type TargetType int16

type Trigger

type Trigger struct {
	TriggerID     TriggerID
	Level         state.State
	TriggerOnExit bool
	PeriodMilli   int32
	TargetType    TargetType
	Target        types.JSONText
}

type TriggerID

type TriggerID int32

type Tx

type Tx struct {
	*sqlx.Tx
	// contains filtered or unexported fields
}

func (*Tx) BatchLoadMonitorLabels

func (tx *Tx) BatchLoadMonitorLabels(mIDs []MonitorID) (map[MonitorID][]*MonitorLabel, error)

func (*Tx) CreateLabel

func (tx *Tx) CreateLabel(l *Label) (LabelID, error)

func (*Tx) CreateLabelMonitor

func (tx *Tx) CreateLabelMonitor(lm LabelMonitor) error

func (*Tx) CreateLabelTrigger

func (tx *Tx) CreateLabelTrigger(lt LabelTrigger) (TriggerID, error)

func (*Tx) CreateMonitor

func (tx *Tx) CreateMonitor(m *Monitor) (MonitorID, error)

func (*Tx) CreateMonitorLabel

func (tx *Tx) CreateMonitorLabel(ml MonitorLabel) error

func (*Tx) CreateMonitorSilence

func (tx *Tx) CreateMonitorSilence(monitorSilence *MonitorSilence) (SilenceID, error)

func (*Tx) CreateMonitorTrigger

func (tx *Tx) CreateMonitorTrigger(mt MonitorTrigger) (TriggerID, error)

func (*Tx) CreateResource

func (tx *Tx) CreateResource(resource *Resource) (ResourceID, error)

func (*Tx) CreateSetting

func (tx *Tx) CreateSetting(s *Setting) (SettingID, error)

func (*Tx) DeleteLabelMonitor

func (tx *Tx) DeleteLabelMonitor(lm LabelMonitor) error

func (*Tx) DeleteLabelTrigger

func (tx *Tx) DeleteLabelTrigger(triggerID TriggerID) error

func (*Tx) DeleteMonitorLabel

func (tx *Tx) DeleteMonitorLabel(ml MonitorLabel) error

func (*Tx) DeleteMonitorTrigger

func (tx *Tx) DeleteMonitorTrigger(triggerID TriggerID) error

func (*Tx) DeleteResource

func (tx *Tx) DeleteResource(id ResourceID) error

func (*Tx) DeleteSetting

func (tx *Tx) DeleteSetting(s *Setting) error

func (*Tx) DeleteSubprobe

func (tx *Tx) DeleteSubprobe(subprobeId int) error

func (*Tx) InsertReading

func (tx *Tx) InsertReading(r Reading) error

func (*Tx) InsertSubprobe

func (tx *Tx) InsertSubprobe(monitorID MonitorID, name string) (SubprobeID, error)

func (*Tx) InsertSubprobeStatus

func (tx *Tx) InsertSubprobeStatus(s SubprobeStatus) error

func (*Tx) LoadLabel

func (tx *Tx) LoadLabel(id LabelID) (*Label, error)

func (*Tx) LoadLabelTriggersForMonitor

func (tx *Tx) LoadLabelTriggersForMonitor(id MonitorID) ([]LabelTriggerWithSubprobes, error)

func (*Tx) LoadLabels

func (tx *Tx) LoadLabels() ([]*Label, error)

func (*Tx) LoadLabelsForMonitor

func (tx *Tx) LoadLabelsForMonitor(id MonitorID) ([]*MonitorLabel, error)

func (*Tx) LoadMonitor

func (tx *Tx) LoadMonitor(id MonitorID) (*Monitor, error)

func (*Tx) LoadMonitorSilence

func (tx *Tx) LoadMonitorSilence(id SilenceID) (*MonitorSilence, error)

func (*Tx) LoadMonitorSilences

func (tx *Tx) LoadMonitorSilences() ([]*MonitorSilence, error)

func (*Tx) LoadMonitors

func (tx *Tx) LoadMonitors() ([]*Monitor, error)

func (*Tx) LoadMonitorsForLabel

func (tx *Tx) LoadMonitorsForLabel(id LabelID) ([]LabelMonitor, error)

func (*Tx) LoadMonitorsWithLabel

func (tx *Tx) LoadMonitorsWithLabel(id LabelID) ([]*Monitor, error)

func (*Tx) LoadProbeByMonitorID

func (tx *Tx) LoadProbeByMonitorID(id MonitorID) (types.JSONText, ProbeType, error)

func (*Tx) LoadResource

func (tx *Tx) LoadResource(id ResourceID) (*Resource, error)

func (*Tx) LoadSubprobeStatusesForMonitor

func (tx *Tx) LoadSubprobeStatusesForMonitor(id MonitorID) (map[string]SubprobeStatus, error)

func (*Tx) LoadSubprobeWithStatusInfo

func (tx *Tx) LoadSubprobeWithStatusInfo(subprobeID SubprobeID) (*SubprobeWithStatusInfo, error)

func (*Tx) LoadSubprobesByName

func (tx *Tx) LoadSubprobesByName(monitorID MonitorID) ([]*SubprobeWithStatusInfo, error)

func (*Tx) LoadSubprobesBySeverity

func (tx *Tx) LoadSubprobesBySeverity() ([]*SubprobeWithStatusInfo, error)

func (*Tx) LoadSubprobesBySeverityForLabel

func (tx *Tx) LoadSubprobesBySeverityForLabel(labelID LabelID) ([]*SubprobeWithStatusInfo, error)

func (*Tx) LoadTriggersForLabel

func (tx *Tx) LoadTriggersForLabel(id LabelID) ([]LabelTrigger, error)

func (*Tx) LoadTriggersForMonitor

func (tx *Tx) LoadTriggersForMonitor(id MonitorID) ([]MonitorTrigger, error)

func (*Tx) Prefix

func (tx *Tx) Prefix() string

Prefix returns the prefix to add to table names in queries.

func (*Tx) Unsafe

func (tx *Tx) Unsafe() *Tx

func (*Tx) UpdateLabel

func (tx *Tx) UpdateLabel(l *Label) error

func (*Tx) UpdateLabelMonitor

func (tx *Tx) UpdateLabelMonitor(lm LabelMonitor) error

func (*Tx) UpdateLabelTrigger

func (tx *Tx) UpdateLabelTrigger(lt LabelTrigger) error

func (*Tx) UpdateMonitor

func (tx *Tx) UpdateMonitor(m *Monitor) error

func (*Tx) UpdateMonitorLabel

func (tx *Tx) UpdateMonitorLabel(ml MonitorLabel) error

func (*Tx) UpdateMonitorSilence

func (tx *Tx) UpdateMonitorSilence(monitorSilence *MonitorSilence) error

func (*Tx) UpdateMonitorTrigger

func (tx *Tx) UpdateMonitorTrigger(mt MonitorTrigger) error

func (*Tx) UpdateResource

func (tx *Tx) UpdateResource(resource *Resource) error

func (*Tx) UpdateSetting

func (tx *Tx) UpdateSetting(s *Setting) error

func (*Tx) UpdateSubprobeStatus

func (tx *Tx) UpdateSubprobeStatus(s SubprobeStatus) error

Jump to

Keyboard shortcuts

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