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" }