repositories

package
v0.0.0-...-3ee0207 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alert

type Alert struct {
	gorm.Model
	Name   string                 `gorm:"unique"`
	Action domain.AlertActionType `gorm:"comment:'Reboot=0, Sleep=1, Normal=2'"`
	State  domain.AlertState      `gorm:"comment:'Monitoring=0, Triggered=1, Resolving=2, Resolved=3'"`
	Active bool                   `gorm:"default:true"`

	Condition []AlertCondition `gorm:"foreignKey:AlertID;references:ID"`
	Log       []AlertLog       `gorm:"foreignKey:AlertID;references:ID"`

	ScannerID uint
}

type AlertCondition

type AlertCondition struct {
	gorm.Model
	TriggerValue  domain.AlertTriggerValue  `gorm:"comment:'Value for threshold (e.g. 100 TH/s, 80°C, and 100 RPM)'"`
	MachineCount  domain.AlertMachineCount  `gorm:"comment:'Number of machines for alert to get triggerred'"`
	ThresholdType domain.AlertThresholdType `gorm:"comment:'ThresholdCount=1, ThresholdRate=1'"`
	ConditionType domain.AlertConditionType `gorm:"comment:'Hashrate=0, Temperature=1, FanSpeed=2, PoolShares=3, OfflineMiners=4, MissingHashboards=5'"`
	LayerType     domain.AlertLayerType     `gorm:"comment:'InfoAlert=0, WarningAlert=1, ErrorAlert=2, FataltAlert=3'"`

	AlertID uint
}

type AlertLog

type AlertLog struct {
	gorm.Model
	Log domain.Log

	AlertID uint
}

type Scanner

type Scanner struct {
	gorm.Model
	Name      string           `gorm:"unique"`
	Scanner   domain.Scanner   `gorm:"embedded;"`
	Config    domain.Config    `gorm:"embedded;"`
	MinerType domain.MinerType `gorm:"comment:'AntMinerCgi=0'"`
	Owner     string

	Alert Alert `gorm:"onDelete:CASCADE; onUpdate:CASCADE"`

	FleetID uint
}

type ScannerRepository

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

TODO: preload with alerts and alert logs NOTE: alert condition order matters

func NewScannerRepository

func NewScannerRepository(db *gorm.DB) *ScannerRepository

func (*ScannerRepository) List

func (r *ScannerRepository) List() ([]*Scanner, error)

func (*ScannerRepository) LogAlert

func (r *ScannerRepository) LogAlert(ctx context.Context, alertLog *AlertLog) (uint, error)

where alert_id = ?

func (*ScannerRepository) Upsert

func (r *ScannerRepository) Upsert(ctx context.Context, scanner *Scanner) (uint, error)

func (*ScannerRepository) UpsertAlert

func (r *ScannerRepository) UpsertAlert(ctx context.Context, alert *Alert) (uint, error)

Jump to

Keyboard shortcuts

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