vm

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: 14 Imported by: 0

Documentation

Overview

Package vm represents the intermediate step between a revere db struct and a renderable front-end struct.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllMonitorLabelsForSubprobes

func AllMonitorLabelsForSubprobes(tx *db.Tx, subprobes []*Subprobe) (map[db.MonitorID][]*MonitorLabel, error)

func DeleteSubprobe

func DeleteSubprobe(tx *db.Tx, subprobeId int) error

func IsLastBc

func IsLastBc(a []Breadcrumb, i int) bool

func LoadActiveSilence

func LoadActiveSilence(db *db.DB, id db.MonitorID, subprobe string) db.SilenceID

func NewProbe

func NewProbe(DB *db.DB, id db.MonitorID) (probe.VM, error)

func PopulateLabelsForMonitors

func PopulateLabelsForMonitors(tx *db.Tx, monitors []*Monitor) error

Types

type Breadcrumb struct {
	Text string
	Link string
}

func LabelIndexBcs

func LabelIndexBcs() []Breadcrumb

func LabelViewBcs

func LabelViewBcs(mn string, id int64) []Breadcrumb

func MonitorIndexBcs

func MonitorIndexBcs() []Breadcrumb

func MonitorViewBcs

func MonitorViewBcs(mn string, id int64) []Breadcrumb

func SilencesIndexBcs

func SilencesIndexBcs() []Breadcrumb

func SilencesViewBcs

func SilencesViewBcs(id int64, mn string) []Breadcrumb

func SubprobeIndexBcs

func SubprobeIndexBcs(mn string, id int64) []Breadcrumb

func SubprobeViewBcs

func SubprobeViewBcs(s *Subprobe) []Breadcrumb

type Component

type Component interface {
	Id() int64
}

type CreatableComponent

type CreatableComponent interface {
	IsCreate() bool
}

type DeletableComponent

type DeletableComponent interface {
	IsDelete() bool
}

type Label

type Label struct {
	LabelID     db.LabelID
	Name        string
	Description string
	Triggers    []*LabelTrigger
	Monitors    []*LabelMonitor
}

func AllLabels

func AllLabels(tx *db.Tx) ([]*Label, error)

func BlankLabel

func BlankLabel() *Label

func NewLabel

func NewLabel(tx *db.Tx, id db.LabelID) (*Label, error)

func (*Label) ComponentName

func (*Label) ComponentName() string

func (*Label) Id

func (l *Label) Id() int64

func (*Label) IsCreate

func (l *Label) IsCreate() bool

func (*Label) Save

func (l *Label) Save(tx *db.Tx) error

func (*Label) Validate

func (l *Label) Validate(db *db.DB) (errs []string)

type LabelMonitor

type LabelMonitor struct {
	// TODO(fchen): Organize struct fields between db-only fields, front-end-only fields, and shared fields
	Monitor   *Monitor
	LabelID   db.LabelID
	Subprobes string
	Create    bool
	Delete    bool
}

func (*LabelMonitor) Id

func (lm *LabelMonitor) Id() int64

func (*LabelMonitor) IsCreate

func (lm *LabelMonitor) IsCreate() bool

func (*LabelMonitor) IsDelete

func (lm *LabelMonitor) IsDelete() bool

type LabelTrigger

type LabelTrigger struct {
	Trigger *Trigger
	LabelID db.LabelID
}

func BlankLabelTrigger

func BlankLabelTrigger() *LabelTrigger

func (*LabelTrigger) Id

func (lt *LabelTrigger) Id() int64

func (*LabelTrigger) IsCreate

func (lt *LabelTrigger) IsCreate() bool

func (*LabelTrigger) IsDelete

func (lt *LabelTrigger) IsDelete() bool

type Monitor

type Monitor struct {
	MonitorID   db.MonitorID
	Name        string
	Owner       string
	Description string
	Response    string
	ProbeType   db.ProbeType
	ProbeParams string
	Changed     time.Time
	Version     int32
	// TODO(fchen): changed and Archived need to match
	Archived *time.Time
	Probe    probe.VM
	Triggers []*MonitorTrigger
	Labels   []*MonitorLabel
}

func AllMonitors

func AllMonitors(tx *db.Tx) ([]*Monitor, error)

func AllMonitorsForLabel

func AllMonitorsForLabel(tx *db.Tx, labelID db.LabelID) ([]*Monitor, error)

func BlankMonitor

func BlankMonitor() (*Monitor, error)

func NewMonitor

func NewMonitor(tx *db.Tx, id db.MonitorID) (*Monitor, error)

func (*Monitor) ComponentName

func (*Monitor) ComponentName() string

func (*Monitor) Id

func (m *Monitor) Id() int64

func (*Monitor) IsCreate

func (m *Monitor) IsCreate() bool

func (*Monitor) Save

func (m *Monitor) Save(tx *db.Tx) error

func (*Monitor) Validate

func (m *Monitor) Validate(DB *db.DB) (errs []string)

type MonitorLabel

type MonitorLabel struct {
	Label     *Label
	MonitorID db.MonitorID
	Subprobes string
	Create    bool
	Delete    bool
}

func (*MonitorLabel) Id

func (ml *MonitorLabel) Id() int64

func (*MonitorLabel) IsCreate

func (ml *MonitorLabel) IsCreate() bool

func (*MonitorLabel) IsDelete

func (ml *MonitorLabel) IsDelete() bool

type MonitorTrigger

type MonitorTrigger struct {
	Trigger   *Trigger
	MonitorID db.MonitorID
	Subprobes string
}

func BlankMonitorTrigger

func BlankMonitorTrigger() *MonitorTrigger

func (*MonitorTrigger) Id

func (mt *MonitorTrigger) Id() int64

func (*MonitorTrigger) IsCreate

func (mt *MonitorTrigger) IsCreate() bool

func (*MonitorTrigger) IsDelete

func (mt *MonitorTrigger) IsDelete() bool

type NamedComponent

type NamedComponent interface {
	Component
	ComponentName() string
}

type Reading

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

func AllReadingsFromSubprobe

func AllReadingsFromSubprobe(DB *db.DB, id db.SubprobeID) ([]*Reading, error)

func BlankReading

func BlankReading() *Reading

func (*Reading) Id

func (r *Reading) Id() int64

type Silence

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

func AllSilences

func AllSilences(tx *db.Tx) ([]*Silence, error)

func BlankSilence

func BlankSilence() *Silence

func NewSilence

func NewSilence(db *db.DB, id db.SilenceID) (*Silence, error)

func (*Silence) ComponentName

func (*Silence) ComponentName() string

func (*Silence) Editable

func (s *Silence) Editable() bool

func (*Silence) Id

func (s *Silence) Id() int64

func (*Silence) IsCreate

func (s *Silence) IsCreate() bool

func (*Silence) IsPast

func (s *Silence) IsPast(moment time.Time) bool

func (*Silence) IsPresent

func (s *Silence) IsPresent(moment time.Time) bool

func (*Silence) Save

func (s *Silence) Save(tx *db.Tx) error

func (*Silence) SetHtmlParams

func (s *Silence) SetHtmlParams(values url.Values) error

func (*Silence) Validate

func (s *Silence) Validate(db *db.DB) (errs []string)

type Subprobe

type Subprobe struct {
	SubprobeID  db.SubprobeID
	MonitorID   db.MonitorID
	MonitorName string
	Name        string
	Archived    *time.Time
	Status      SubprobeStatus
}

func AllAbnormalSubprobes

func AllAbnormalSubprobes(tx *db.Tx) ([]*Subprobe, error)

func AllAbnormalSubprobesForLabel

func AllAbnormalSubprobesForLabel(tx *db.Tx, id db.LabelID) ([]*Subprobe, error)

func AllSubprobesFromMonitor

func AllSubprobesFromMonitor(tx *db.Tx, id db.MonitorID) ([]*Subprobe, error)

func BlankSubprobe

func BlankSubprobe() *Subprobe

func NewSubprobe

func NewSubprobe(DB *db.DB, id db.SubprobeID) (*Subprobe, error)

func (*Subprobe) Id

func (s *Subprobe) Id() int64

type SubprobeStatus

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

type Trigger

type Trigger struct {
	TriggerID     db.TriggerID
	Level         state.State
	LevelText     string
	Period        int32
	PeriodType    string
	TargetType    db.TargetType
	TargetParams  string
	TriggerOnExit bool
	Target        target.VM
	Delete        bool
}

func BlankTrigger

func BlankTrigger() *Trigger

func (*Trigger) Id

func (t *Trigger) Id() int64

Directories

Path Synopsis
Package renderables processes package vm structs and bundles them with the appropriate metadata, html templates, and scripts to create a fully functional web page.
Package renderables processes package vm structs and bundles them with the appropriate metadata, html templates, and scripts to create a fully functional web page.

Jump to

Keyboard shortcuts

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