Files
worker/app/models/worker_log_event.go
Gleb Tv 2c7a0236da feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
2026-07-13 17:55:14 +03:00

32 строки
1.2 KiB
Go

package models
import (
"time"
"gorm.io/datatypes"
"rsgit.ru/rsmon/rsmon/app/models/concerns"
)
// WorkerLogEvent stores critical log events sent by worker nodes. The same
// payload may also be forwarded to VictoriaLogs; Postgres keeps a compact audit
// copy so the control plane can show recent critical events even if external log
// storage is temporarily unavailable.
type WorkerLogEvent struct {
concerns.Model
WorkerID int64 `gorm:"type:bigint REFERENCES worker_nodes(id) ON DELETE SET NULL;index" json:"worker_id"`
WorkerNodeID string `gorm:"size:100;not null;index" json:"worker_node_id"`
ServerID *int64 `gorm:"type:bigint REFERENCES servers(id) ON DELETE SET NULL;index" json:"server_id,omitempty"`
Level string `gorm:"size:16;not null;index" json:"level"`
Message string `gorm:"type:text;not null" json:"message"`
Source string `gorm:"size:64" json:"source"`
Payload datatypes.JSON `gorm:"type:jsonb;not null;default:'{}'::jsonb" json:"payload"`
OccurredAt time.Time `gorm:"not null;index" json:"occurred_at"`
concerns.Timestamped
}
// TableName provides functionality.
func (WorkerLogEvent) TableName() string { return "worker_log_events" }