2024-02-11 10:56:21 +00:00
|
|
|
package models
|
|
|
|
|
2024-02-15 22:47:56 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
2024-02-19 10:43:43 +00:00
|
|
|
"github.com/lib/pq"
|
2024-02-15 22:47:56 +00:00
|
|
|
"gorm.io/gorm"
|
|
|
|
)
|
2024-02-12 08:25:11 +00:00
|
|
|
|
|
|
|
type OAuth2State struct {
|
|
|
|
State string `gorm:"primary_key"`
|
|
|
|
Expiry time.Time
|
|
|
|
}
|
|
|
|
|
2024-02-18 21:37:17 +00:00
|
|
|
type Worker struct {
|
|
|
|
gorm.Model
|
|
|
|
Name string `gorm:"unique" validate:"required"`
|
|
|
|
Slug string `gorm:"unique"`
|
2024-02-19 09:09:30 +00:00
|
|
|
Group string `validate:"required"`
|
2024-02-18 21:37:17 +00:00
|
|
|
Status string
|
|
|
|
}
|
|
|
|
|
2024-02-22 16:29:17 +00:00
|
|
|
const (
|
|
|
|
HealthcheckSuccess string = "SUCCESS"
|
|
|
|
HealthcheckFailure string = "FAILURE"
|
|
|
|
HealthcheckError string = "ERROR"
|
|
|
|
HealthcheckUnknown string = "UNKNOWN"
|
|
|
|
)
|
|
|
|
|
2024-02-11 10:56:21 +00:00
|
|
|
type Healthcheck struct {
|
2024-02-15 22:47:56 +00:00
|
|
|
gorm.Model
|
2024-02-21 09:06:54 +00:00
|
|
|
Slug string `gorm:"unique"`
|
|
|
|
Name string `gorm:"unique" validate:"required"`
|
2024-02-15 22:47:56 +00:00
|
|
|
|
2024-02-21 09:06:54 +00:00
|
|
|
Schedule string `validate:"required,cron"`
|
|
|
|
WorkerGroups pq.StringArray `gorm:"type:text[]"`
|
2024-02-20 10:24:04 +00:00
|
|
|
|
2024-02-21 09:06:54 +00:00
|
|
|
Script string `validate:"required"`
|
2024-02-15 22:47:56 +00:00
|
|
|
|
2024-02-22 16:29:17 +00:00
|
|
|
History []HealthcheckHistory `gorm:"foreignKey:Healthcheck"`
|
2024-02-15 22:47:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type Cronjob struct {
|
|
|
|
gorm.Model
|
2024-02-16 12:41:18 +00:00
|
|
|
Slug string `gorm:"unique"`
|
2024-02-15 22:47:56 +00:00
|
|
|
Name string `gorm:"unique"`
|
|
|
|
Schedule string
|
|
|
|
Buffer int
|
2024-02-11 10:56:21 +00:00
|
|
|
}
|
2024-02-16 12:07:29 +00:00
|
|
|
|
2024-02-21 09:06:54 +00:00
|
|
|
type HealthcheckHistory struct {
|
2024-02-16 12:07:29 +00:00
|
|
|
gorm.Model
|
2024-02-22 16:29:17 +00:00
|
|
|
Healthcheck uint
|
|
|
|
Status string
|
2024-02-21 22:15:21 +00:00
|
|
|
Note string
|
2024-02-16 12:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type CronjobHistory struct {
|
|
|
|
gorm.Model
|
|
|
|
Cronjob Cronjob `gorm:"foreignkey:ID"`
|
|
|
|
Status string
|
|
|
|
}
|