Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package types contains all of the structs for objects in Statping including services, hits, failures, Core, and others.
More info on: https://github.com/hunterlong/statping
Index ¶
- Constants
 - Variables
 - type AllNotifiers
 - type Asseter
 - type Checkin
 - type CheckinHit
 - type CheckinInterface
 - type Core
 - type Databaser
 - type DbConfig
 - type FailSort
 - type Failure
 - type FailureInterface
 - type Group
 - type Hit
 - type Incident
 - type IncidentUpdate
 - type Info
 - type Message
 - type NullBool
 - type NullFloat64
 - type NullInt64
 - type NullString
 - type Plugin
 - type PluginActions
 - type PluginInfo
 - type PluginJSON
 - type PluginObject
 - type PluginRepos
 - type PluginRoute
 - type PluginRouting
 - type Pluginer
 - type Router
 - type Service
 - type ServiceInterface
 - type User
 - type UserInterface
 
Constants ¶
const ( TIME_NANO = "2006-01-02T15:04:05Z" TIME = "2006-01-02 15:04:05" CHART_TIME = "2006-01-02T15:04:05.999999-07:00" TIME_DAY = "2006-01-02" )
Variables ¶
var (
	NOW = func() time.Time { return time.Now() }()
)
    Functions ¶
This section is empty.
Types ¶
type AllNotifiers ¶ added in v0.79.1
type AllNotifiers interface{}
    AllNotifiers contains all the Notifiers loaded
type Checkin ¶ added in v0.27.7
type Checkin struct {
	Id          int64              `gorm:"primary_key;column:id" json:"id"`
	ServiceId   int64              `gorm:"index;column:service" json:"service_id"`
	Name        string             `gorm:"column:name" json:"name"`
	Interval    int64              `gorm:"column:check_interval" json:"interval"`
	GracePeriod int64              `gorm:"column:grace_period"  json:"grace"`
	ApiKey      string             `gorm:"column:api_key"  json:"api_key"`
	CreatedAt   time.Time          `gorm:"column:created_at" json:"created_at"`
	UpdatedAt   time.Time          `gorm:"column:updated_at" json:"updated_at"`
	Running     chan bool          `gorm:"-" json:"-"`
	Failing     bool               `gorm:"-" json:"failing"`
	LastHit     time.Time          `gorm:"-" json:"last_hit"`
	Hits        []*CheckinHit      `gorm:"-" json:"hits"`
	Failures    []FailureInterface `gorm:"-" json:"failures"`
}
    Checkin struct will allow an application to send a recurring HTTP GET to confirm a service is online
func (*Checkin) BeforeCreate ¶ added in v0.80.5
BeforeCreate for Checkin will set CreatedAt to UTC
func (*Checkin) Close ¶ added in v0.79.1
func (s *Checkin) Close()
Close will stop the checkin routine
type CheckinHit ¶ added in v0.79.1
type CheckinHit struct {
	Id        int64     `gorm:"primary_key;column:id" json:"id"`
	Checkin   int64     `gorm:"index;column:checkin" json:"-"`
	From      string    `gorm:"column:from_location" json:"from"`
	CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
}
    CheckinHit is a successful response from a Checkin
func (*CheckinHit) BeforeCreate ¶ added in v0.80.5
func (c *CheckinHit) BeforeCreate() (err error)
BeforeCreate for checkinHit will set CreatedAt to UTC
type CheckinInterface ¶ added in v0.79.98
type CheckinInterface interface {
	Select() *Checkin
}
    type Core ¶ added in v0.79.1
type Core struct {
	Name          string             `gorm:"not null;column:name" json:"name"`
	Description   string             `gorm:"not null;column:description" json:"description,omitempty"`
	Config        string             `gorm:"column:config" json:"-"`
	ApiKey        string             `gorm:"column:api_key" json:"-"`
	ApiSecret     string             `gorm:"column:api_secret" json:"-"`
	Style         string             `gorm:"not null;column:style" json:"style,omitempty"`
	Domain        string             `gorm:"not null;column:domain" json:"domain"`
	Version       string             `gorm:"column:version" json:"version"`
	MigrationId   int64              `gorm:"column:migration_id" json:"migration_id,omitempty"`
	UseCdn        NullBool           `gorm:"column:use_cdn;default:false" json:"using_cdn,omitempty"`
	Timezone      float32            `gorm:"column:timezone;default:-8.0" json:"timezone,omitempty"`
	CreatedAt     time.Time          `gorm:"column:created_at" json:"created_at"`
	UpdatedAt     time.Time          `gorm:"column:updated_at" json:"updated_at"`
	DbConnection  string             `gorm:"-" json:"database"`
	Started       time.Time          `gorm:"-" json:"started_on"`
	Services      []ServiceInterface `gorm:"-" json:"-"`
	Plugins       []*Info            `gorm:"-" json:"-"`
	Repos         []PluginJSON       `gorm:"-" json:"-"`
	AllPlugins    []PluginActions    `gorm:"-" json:"-"`
	Notifications []AllNotifiers     `gorm:"-" json:"-"`
}
    Core struct contains all the required fields for Statping. All application settings will be saved into 1 row in the 'core' table. You can use the core.CoreApp global variable to interact with the attributes to the application, such as services.
type DbConfig ¶ added in v0.27.7
type DbConfig struct {
	DbConn      string `yaml:"connection"`
	DbHost      string `yaml:"host"`
	DbUser      string `yaml:"user"`
	DbPass      string `yaml:"password"`
	DbData      string `yaml:"database"`
	DbPort      int64  `yaml:"port"`
	ApiKey      string `yaml:"api_key"`
	ApiSecret   string `yaml:"api_secret"`
	Project     string `yaml:"-"`
	Description string `yaml:"-"`
	Domain      string `yaml:"-"`
	Username    string `yaml:"-"`
	Password    string `yaml:"-"`
	Email       string `yaml:"-"`
	Error       error  `yaml:"-"`
	Location    string `yaml:"location"`
	LocalIP     string `yaml:"-"`
}
    DbConfig struct is used for the database connection and creates the 'config.yml' file
type FailSort ¶ added in v0.79.9
type FailSort []FailureInterface
type Failure ¶ added in v0.27.7
type Failure struct {
	Id        int64     `gorm:"primary_key;column:id" json:"id"`
	Issue     string    `gorm:"column:issue" json:"issue"`
	Method    string    `gorm:"column:method" json:"method,omitempty"`
	MethodId  int64     `gorm:"column:method_id" json:"method_id,omitempty"`
	ErrorCode int       `gorm:"column:error_code" json:"error_code"`
	Service   int64     `gorm:"index;column:service" json:"-"`
	Checkin   int64     `gorm:"index;column:checkin" json:"-"`
	PingTime  float64   `gorm:"column:ping_time"  json:"ping"`
	CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
}
    Failure is a failed attempt to check a service. Any a service does not meet the expected requirements, a new Failure will be inserted into database.
func (*Failure) BeforeCreate ¶ added in v0.80.5
BeforeCreate for Failure will set CreatedAt to UTC
type FailureInterface ¶ added in v0.79.1
type Group ¶ added in v0.80.5
type Group struct {
	Id        int64     `gorm:"primary_key;column:id" json:"id"`
	Name      string    `gorm:"column:name" json:"name"`
	Public    NullBool  `gorm:"default:true;column:public" json:"public"`
	Order     int       `gorm:"default:0;column:order_id" json:"order_id"`
	CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt time.Time `gorm:"column:updated_at" json:"updated_at"`
}
    Group is the main struct for Groups
type Hit ¶ added in v0.27.7
type Hit struct {
	Id        int64     `gorm:"primary_key;column:id" json:"id"`
	Service   int64     `gorm:"column:service" json:"-"`
	Latency   float64   `gorm:"column:latency" json:"latency"`
	PingTime  float64   `gorm:"column:ping_time" json:"ping_time"`
	CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
}
    Hit struct is a 'successful' ping or web response entry for a service.
func (*Hit) BeforeCreate ¶ added in v0.80.5
BeforeCreate for Hit will set CreatedAt to UTC
type Incident ¶ added in v0.80.63
type Incident struct {
	Id          int64             `gorm:"primary_key;column:id" json:"id"`
	Title       string            `gorm:"column:title" json:"title,omitempty"`
	Description string            `gorm:"column:description" json:"description,omitempty"`
	ServiceId   int64             `gorm:"index;column:service" json:"service"`
	CreatedAt   time.Time         `gorm:"column:created_at" json:"created_at" json:"created_at"`
	UpdatedAt   time.Time         `gorm:"column:updated_at" json:"updated_at" json:"updated_at"`
	Updates     []*IncidentUpdate `gorm:"-" json:"updates,omitempty"`
}
    Incident is the main struct for Incidents
type IncidentUpdate ¶ added in v0.80.63
type IncidentUpdate struct {
	Id         int64     `gorm:"primary_key;column:id" json:"id"`
	IncidentId int64     `gorm:"index;column:incident" json:"-"`
	Message    string    `gorm:"column:message" json:"message,omitempty"`
	Type       string    `gorm:"column:type" json:"type,omitempty"`
	CreatedAt  time.Time `gorm:"column:created_at" json:"created_at" json:"created_at"`
	UpdatedAt  time.Time `gorm:"column:updated_at" json:"updated_at" json:"updated_at"`
}
    IncidentUpdate contains updates based on a Incident
type Message ¶ added in v0.79.4
type Message struct {
	Id                int64     `gorm:"primary_key;column:id" json:"id"`
	Title             string    `gorm:"column:title" json:"title"`
	Description       string    `gorm:"column:description" json:"description"`
	StartOn           time.Time `gorm:"column:start_on" json:"start_on"`
	EndOn             time.Time `gorm:"column:end_on" json:"end_on"`
	ServiceId         int64     `gorm:"index;column:service" json:"service"`
	NotifyUsers       NullBool  `gorm:"column:notify_users" json:"notify_users"`
	NotifyMethod      string    `gorm:"column:notify_method" json:"notify_method"`
	NotifyBefore      NullInt64 `gorm:"column:notify_before" json:"notify_before"`
	NotifyBeforeScale string    `gorm:"column:notify_before_scale" json:"notify_before_scale"`
	CreatedAt         time.Time `gorm:"column:created_at" json:"created_at" json:"created_at"`
	UpdatedAt         time.Time `gorm:"column:updated_at" json:"updated_at" json:"updated_at"`
}
    Message is for creating Announcements, Alerts and other messages for the end users
func (*Message) BeforeCreate ¶ added in v0.80.5
BeforeCreate for Message will set CreatedAt to UTC
type NullBool ¶ added in v0.79.4
NullBool is an alias for sql.NullBool data type
func NewNullBool ¶ added in v0.79.4
NewNullBool returns a sql.NullBool for JSON parsing
func (*NullBool) MarshalJSON ¶ added in v0.79.4
MarshalJSON for NullBool
func (*NullBool) UnmarshalJSON ¶ added in v0.79.4
Unmarshaler for NullBool
type NullFloat64 ¶ added in v0.79.4
type NullFloat64 struct {
	sql.NullFloat64
}
    NullFloat64 is an alias for sql.NullFloat64 data type
func NewNullFloat64 ¶ added in v0.79.4
func NewNullFloat64(s float64) NullFloat64
NewNullFloat64 returns a sql.NullFloat64 for JSON parsing
func (*NullFloat64) MarshalJSON ¶ added in v0.79.4
func (ni *NullFloat64) MarshalJSON() ([]byte, error)
MarshalJSON for NullFloat64
func (*NullFloat64) UnmarshalJSON ¶ added in v0.79.4
func (nf *NullFloat64) UnmarshalJSON(b []byte) error
Unmarshaler for NullFloat64
type NullInt64 ¶ added in v0.79.4
NullInt64 is an alias for sql.NullInt64 data type
func NewNullInt64 ¶ added in v0.79.4
NewNullInt64 returns a sql.NullInt64 for JSON parsing
func (*NullInt64) MarshalJSON ¶ added in v0.79.4
MarshalJSON for NullInt64
func (*NullInt64) UnmarshalJSON ¶ added in v0.79.4
Unmarshaler for NullInt64
type NullString ¶ added in v0.79.4
type NullString struct {
	sql.NullString
}
    NullString is an alias for sql.NullString data type
func NewNullString ¶ added in v0.79.4
func NewNullString(s string) NullString
NewNullString returns a sql.NullString for JSON parsing
func (*NullString) MarshalJSON ¶ added in v0.79.4
func (ns *NullString) MarshalJSON() ([]byte, error)
MarshalJSON for NullString
func (*NullString) UnmarshalJSON ¶ added in v0.79.4
func (nf *NullString) UnmarshalJSON(b []byte) error
Unmarshaler for NullString
type PluginActions ¶ added in v0.79.1
type PluginInfo ¶ added in v0.79.1
type PluginInfo struct {
	Info   *Info
	Routes []*PluginRoute
}
    type PluginJSON ¶ added in v0.27.7
type PluginObject ¶ added in v0.79.1
type PluginObject struct {
	Pluginer
}
    type PluginRepos ¶ added in v0.27.7
type PluginRepos struct {
	Plugins []PluginJSON
}
    type PluginRoute ¶ added in v0.79.1
type PluginRoute struct {
	Url    string
	Method string
	Func   http.HandlerFunc
}
    type PluginRouting ¶ added in v0.79.1
type Router ¶ added in v0.79.1
type Router interface {
	Routes() []*PluginRoute
	AddRoute(string, string, http.HandlerFunc) error
}
    type Service ¶ added in v0.79.1
type Service struct {
	Id                 int64              `gorm:"primary_key;column:id" json:"id"`
	Name               string             `gorm:"column:name" json:"name"`
	Domain             string             `gorm:"column:domain" json:"domain"`
	Expected           NullString         `gorm:"column:expected" json:"expected"`
	ExpectedStatus     int                `gorm:"default:200;column:expected_status" json:"expected_status"`
	Interval           int                `gorm:"default:30;column:check_interval" json:"check_interval"`
	Type               string             `gorm:"column:check_type" json:"type"`
	Method             string             `gorm:"column:method" json:"method"`
	PostData           NullString         `gorm:"column:post_data" json:"post_data"`
	Port               int                `gorm:"not null;column:port" json:"port"`
	Timeout            int                `gorm:"default:30;column:timeout" json:"timeout"`
	Order              int                `gorm:"default:0;column:order_id" json:"order_id"`
	AllowNotifications NullBool           `gorm:"default:true;column:allow_notifications" json:"allow_notifications"`
	Public             NullBool           `gorm:"default:true;column:public" json:"public"`
	GroupId            int                `gorm:"default:0;column:group_id" json:"group_id"`
	Headers            NullString         `gorm:"column:headers" json:"headers"`
	Permalink          NullString         `gorm:"column:permalink" json:"permalink"`
	CreatedAt          time.Time          `gorm:"column:created_at" json:"created_at"`
	UpdatedAt          time.Time          `gorm:"column:updated_at" json:"updated_at"`
	Online             bool               `gorm:"-" json:"online"`
	Latency            float64            `gorm:"-" json:"latency"`
	PingTime           float64            `gorm:"-" json:"ping_time"`
	Online24Hours      float32            `gorm:"-" json:"online_24_hours"`
	AvgResponse        string             `gorm:"-" json:"avg_response"`
	Running            chan bool          `gorm:"-" json:"-"`
	Checkpoint         time.Time          `gorm:"-" json:"-"`
	SleepDuration      time.Duration      `gorm:"-" json:"-"`
	LastResponse       string             `gorm:"-" json:"-"`
	LastStatusCode     int                `gorm:"-" json:"status_code"`
	LastOnline         time.Time          `gorm:"-" json:"last_success"`
	Failures           []FailureInterface `gorm:"-" json:"failures,omitempty"`
	Checkins           []CheckinInterface `gorm:"-" json:"checkins,omitempty"`
}
    Service is the main struct for Services
func (*Service) BeforeCreate ¶ added in v0.80.5
BeforeCreate for Service will set CreatedAt to UTC
func (*Service) Close ¶ added in v0.79.1
func (s *Service) Close()
Close will stop the go routine that is checking if service is online or not
type ServiceInterface ¶ added in v0.79.1
type User ¶ added in v0.27.7
type User struct {
	Id            int64     `gorm:"primary_key;column:id" json:"id"`
	Username      string    `gorm:"type:varchar(100);unique;column:username;" json:"username,omitempty"`
	Password      string    `gorm:"column:password" json:"password,omitempty"`
	Email         string    `gorm:"type:varchar(100);unique;column:email" json:"email,omitempty"`
	ApiKey        string    `gorm:"column:api_key" json:"api_key,omitempty"`
	ApiSecret     string    `gorm:"column:api_secret" json:"api_secret,omitempty"`
	Admin         NullBool  `gorm:"column:administrator" json:"admin,omitempty"`
	CreatedAt     time.Time `gorm:"column:created_at" json:"created_at"`
	UpdatedAt     time.Time `gorm:"column:updated_at" json:"updated_at"`
	UserInterface `gorm:"-" json:"-"`
}
    User is the main struct for Users
func (*User) BeforeCreate ¶ added in v0.80.5
BeforeCreate for User will set CreatedAt to UTC