From 57c8c86c3acce35646055d7b7ac36d8a917c0cf9 Mon Sep 17 00:00:00 2001 From: ostiwe Date: Sun, 10 Aug 2025 22:19:53 +0300 Subject: [PATCH] refactor(model): Refactor Status model --- model/status.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/model/status.go b/model/status.go index c7b2cbe..655d9b2 100644 --- a/model/status.go +++ b/model/status.go @@ -6,18 +6,20 @@ import ( "gorm.io/gorm" ) +type StatusCode string + const ( - StatusOK = "ok" // Means - response ok, service is alive - StatusFailed = "failed" // Means - response failed, all tries failed, service down - StatusWarn = "warn" // Means - response failed after N tries and still watched + StatusOK StatusCode = "ok" // Means - response ok, service is alive + StatusFailed StatusCode = "failed" // Means - response failed, all tries failed, service down + StatusWarn StatusCode = "warn" // Means - response failed after N tries and still watched ) type Status struct { - ID int `gorm:"primary_key;auto_increment" json:"-"` - ServiceID int `gorm:"one" json:"-"` - Status string `gorm:"size:255;not null" json:"status"` - Description *string `gorm:"size:255" json:"description"` - CreatedAt time.Time `json:"created_at"` + ID int `gorm:"primary_key;auto_increment" json:"-"` + ServiceID int `gorm:"one" json:"-"` + Status StatusCode `gorm:"size:255;not null" json:"status"` + Description *string `gorm:"size:255" json:"description"` + CreatedAt time.Time `json:"created_at"` } func (Status) TableName() string {