system_service_status.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package models
  2. import (
  3. "database/sql"
  4. "time"
  5. "github.com/google/uuid"
  6. "gorm.io/gorm"
  7. )
  8. // SystemServiceStatus represents a status entry in a database for a single service in a specific cluster
  9. type SystemServiceStatus struct {
  10. gorm.Model
  11. // ID is a unique identifier for a given event
  12. ID uuid.UUID `gorm:"type:uuid;primaryKey" json:"id"`
  13. // CreatedAt is the time (UTC) that a given status was created. This should not change.
  14. CreatedAt time.Time `json:"created_at"`
  15. // UpdatedAt is the time (UTC) that the status was last updated.
  16. UpdatedAt time.Time `json:"updated_at"`
  17. // StartTime is the time at which the status was first observed
  18. StartTime sql.NullTime `db:"start_time"`
  19. // EndTime is the time at which the status was last observed
  20. // If null, this means the status might not have been resolved yet
  21. EndTime sql.NullTime `db:"end_time"`
  22. // ProjectID is the ID of the project that this app belongs to
  23. ProjectID uint `db:"project_id"`
  24. // ClusterID is the ID of the cluster that this app belongs to
  25. ClusterID uint `db:"cluster_id"`
  26. // the type of kubernetes object this service is
  27. InvolvedObjectType string `db:"involved_object_type"`
  28. Name string `db:"name"`
  29. Namespace string `db:"namespace"`
  30. Severity string `db:"severity"`
  31. // Any other relevant metadata. This field allows us to be flexible in the future.
  32. Metadata JSONB `json:"metadata" sql:"type:jsonb" gorm:"type:jsonb"`
  33. }
  34. // TableName overrides the table name
  35. func (SystemServiceStatus) TableName() string {
  36. return "system_service_status_v2"
  37. }