database

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Check

type Check struct {
	ID           uint `gorm:"primaryKey"`
	MonitorID    uint
	Timestamp    time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	ResponseTime int
	IsUp         bool
	CertExpiry   *time.Time
	CreatedAt    time.Time
	UpdatedAt    time.Time
}

type DB

type DB struct {
	*gorm.DB
}

func NewDB

func NewDB(dataSourceName string) (*DB, error)

func (*DB) AddMonitor

func (db *DB) AddMonitor(name, url string) error

func (*DB) AddStats

func (db *DB) AddStats(monitorName string, responseTime int, isUp bool, certExpiry time.Time) error

func (*DB) GetHistoricalStats

func (db *DB) GetHistoricalStats(monitorID int, count int) ([]types.HistoricalStat, error)

func (*DB) GetStats

func (db *DB) GetStats(monitorName string, duration time.Duration) (types.ServiceStatus, error)

func (*DB) Init

func (db *DB) Init() error

func (*DB) ListMonitors

func (db *DB) ListMonitors() ([]types.Monitor, error)

func (*DB) PauseMonitor

func (db *DB) PauseMonitor(name string) error

func (*DB) RemoveMonitor

func (db *DB) RemoveMonitor(name string) error

func (*DB) ResumeMonitor

func (db *DB) ResumeMonitor(name string) error

type Monitor

type Monitor struct {
	ID        uint           `gorm:"primaryKey"`
	URL       string         `gorm:"uniqueIndex;not null"`
	Name      string         `gorm:"not null"`
	IsActive  bool           `gorm:"default:true"`
	States    []MonitorState `gorm:"foreignKey:MonitorID"`
	Checks    []Check        `gorm:"foreignKey:MonitorID"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

type MonitorState

type MonitorState struct {
	ID        uint `gorm:"primaryKey"`
	MonitorID uint
	State     string    `gorm:"not null"`
	StartedAt time.Time `gorm:"not null"`
	CreatedAt time.Time
	UpdatedAt time.Time
}

Jump to

Keyboard shortcuts

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