feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
48
app/models/message.go
Обычный файл
48
app/models/message.go
Обычный файл
@@ -0,0 +1,48 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/app/models/concerns"
|
||||
)
|
||||
|
||||
// Message info about performed notification
|
||||
type Message struct {
|
||||
concerns.Model
|
||||
|
||||
NotificationID int64 `json:"notification_id"`
|
||||
Notification *Notification `json:"notification,omitempty"`
|
||||
|
||||
ContactID int64 `gorm:"index;type:bigint REFERENCES contacts(id)" json:"contact_id"`
|
||||
Contact *Contact `json:"contact,omitempty"`
|
||||
|
||||
// Events are for up/down messages
|
||||
Events []Event `json:"events" gorm:"many2many:event_messages;"`
|
||||
|
||||
// Checks are for expires messages
|
||||
CheckID *int64 `gorm:"index;type:bigint REFERENCES checks(id)" json:"check_id"`
|
||||
Check *Check `json:"check,omitempty"`
|
||||
|
||||
Kind string `json:"kind"`
|
||||
State string `json:"state"`
|
||||
Error *string `json:"error"`
|
||||
Response *string `json:"response"`
|
||||
Tries int `json:"-"`
|
||||
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
SentAt time.Time `json:"sent_at"`
|
||||
}
|
||||
|
||||
// MessageScope provides functionality.
|
||||
func MessageScope(q *gorm.DB) *gorm.DB {
|
||||
return q.
|
||||
Preload("Events").
|
||||
Preload("Events.Checks").
|
||||
Preload("Events.Monitor").
|
||||
Preload("Notification").
|
||||
Preload("Contact").
|
||||
Preload("Check").
|
||||
Preload("Check.Monitor")
|
||||
}
|
||||
Ссылка в новой задаче
Block a user