model

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPConfig

type HTTPConfig struct {
	Method  string            `json:"method"`
	Headers map[string]string `json:"headers"`
}

type Service

type Service struct {
	// Unique ID for entity
	ID uint64 `gorm:"primary_key;auto_increment" json:"id"`
	// Human-readable service name
	Name string `gorm:"size:255;not null" json:"name"`
	// Human-readable service description
	Description       string `gorm:"size:255" json:"description"`
	PublicDescription string `gorm:"size:255" json:"publicDescription"`
	Public            *bool  `gorm:"default:false" json:"public"`
	// Host to check, for example 192.168.1.44 or https://google.com
	Host string `gorm:"size:255;not null" json:"host"`
	// Type for check, for now is TCP or HTTP or something else
	Type   string                  `gorm:"size:255;not null" json:"type"`
	Config *ServiceTypeCheckConfig `gorm:"serializer:json;column:type_config" json:"typeConfig"`

	Statuses []Status `gorm:"foreignkey:ServiceID" json:"statuses"`
}

func (Service) CalculateUptimePercent

func (s Service) CalculateUptimePercent() float64

func (Service) CountLastStatuses

func (s Service) CountLastStatuses(status StatusCode) uint

func (Service) TableName

func (Service) TableName() string

type ServiceTypeCheckConfig

type ServiceTypeCheckConfig struct {
	Version    string      `json:"version"`
	HTTPConfig *HTTPConfig `json:"httpConfig"`
	// MaxFails - max "ping" fails, after with the service marked as unavailable
	MaxFails uint8 `json:"maxFails"`
	// Interval - interval between "ping" in seconds
	Interval uint64 `json:"interval"`
	// Timeout - interval after which the task will be canceled
	Timeout uint64 `json:"timeout"`
}

type Status

type Status struct {
	ID           uint64     `gorm:"primary_key;auto_increment" json:"-"`
	ServiceID    uint64     `json:"-"`
	Status       StatusCode `gorm:"size:255;not null" json:"status"`
	Description  *string    `gorm:"size:255" json:"description"`
	CreatedAt    time.Time  `json:"createdAt"`
	ResponseTime uint64     `json:"responseTime"`
}

func (*Status) BeforeCreate

func (s *Status) BeforeCreate(*gorm.DB) error

func (Status) TableName

func (Status) TableName() string

type StatusCode

type StatusCode string
const (
	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
	StatusUncheck StatusCode = "uncheck"
)

type User

type User struct {
	ID        uint64    `json:"id"`
	Login     string    `json:"login"`
	Password  string    `json:"-"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

func (*User) BeforeUpdate

func (u *User) BeforeUpdate(*gorm.DB) error

func (*User) TableName

func (*User) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL