Files
worker/app/models/worker_log_event.go
Gleb Tv 2c884c5612
Некоторые проверки не удались
CI / test (push) Successful in 2m5s
Docker / Build and publish worker image (push) Failing after 31s
refactor: adopt worker module path
2026-07-13 17:56:12 +03:00

32 строки
1.2 KiB
Go

package models
import (
"time"
"gorm.io/datatypes"
"rocketgit.ru/rsmon/worker/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" }