statping: github.com/hunterlong/statping/types Index | Files

package types

import "github.com/hunterlong/statping/types"

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

Package Files

checkin.go core.go doc.go failure.go group.go incident.go message.go null.go plugin.go service.go time.go types.go user.go

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() }()
)

type AllNotifiers Uses

type AllNotifiers interface{}

AllNotifiers contains all the Notifiers loaded

type Asseter Uses

type Asseter interface {
    Asset(string) ([]byte, error)
}

type Checkin Uses

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 Uses

func (c *Checkin) BeforeCreate() (err error)

BeforeCreate for Checkin will set CreatedAt to UTC

func (*Checkin) Close Uses

func (s *Checkin) Close()

Close will stop the checkin routine

func (*Checkin) IsRunning Uses

func (s *Checkin) IsRunning() bool

IsRunning returns true if the checkin go routine is running

func (*Checkin) Start Uses

func (s *Checkin) Start()

Start will create a channel for the checkin checking go routine

type CheckinHit Uses

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 Uses

func (c *CheckinHit) BeforeCreate() (err error)

BeforeCreate for checkinHit will set CreatedAt to UTC

type CheckinInterface Uses

type CheckinInterface interface {
    Select() *Checkin
}

type Core Uses

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"`
    Footer        NullString         `gorm:"column:footer" json:"footer"`
    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 Databaser Uses

type Databaser interface {
    StatpingDatabase(*gorm.DB)
}

type DbConfig Uses

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 Uses

type FailSort []FailureInterface

func (FailSort) Len Uses

func (s FailSort) Len() int

func (FailSort) Less Uses

func (s FailSort) Less(i, j int) bool

func (FailSort) Swap Uses

func (s FailSort) Swap(i, j int)

type Failure Uses

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 Uses

func (f *Failure) BeforeCreate() (err error)

BeforeCreate for Failure will set CreatedAt to UTC

type FailureInterface Uses

type FailureInterface interface {
    Select() *Failure
    Ago() string        // Ago returns a human readable timestamp
    ParseError() string // ParseError returns a human readable error for a service failure
}

type Group Uses

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 Uses

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 Uses

func (h *Hit) BeforeCreate() (err error)

BeforeCreate for Hit will set CreatedAt to UTC

type Incident Uses

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 Uses

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 Info Uses

type Info struct {
    Name        string
    Description string
    Form        string
}

type Message Uses

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 Uses

func (u *Message) BeforeCreate() (err error)

BeforeCreate for Message will set CreatedAt to UTC

type NullBool Uses

type NullBool struct {
    sql.NullBool
}

NullBool is an alias for sql.NullBool data type

func NewNullBool Uses

func NewNullBool(s bool) NullBool

NewNullBool returns a sql.NullBool for JSON parsing

func (*NullBool) MarshalJSON Uses

func (nb *NullBool) MarshalJSON() ([]byte, error)

MarshalJSON for NullBool

func (*NullBool) UnmarshalJSON Uses

func (nf *NullBool) UnmarshalJSON(b []byte) error

Unmarshaler for NullBool

type NullFloat64 Uses

type NullFloat64 struct {
    sql.NullFloat64
}

NullFloat64 is an alias for sql.NullFloat64 data type

func NewNullFloat64 Uses

func NewNullFloat64(s float64) NullFloat64

NewNullFloat64 returns a sql.NullFloat64 for JSON parsing

func (*NullFloat64) MarshalJSON Uses

func (ni *NullFloat64) MarshalJSON() ([]byte, error)

MarshalJSON for NullFloat64

func (*NullFloat64) UnmarshalJSON Uses

func (nf *NullFloat64) UnmarshalJSON(b []byte) error

Unmarshaler for NullFloat64

type NullInt64 Uses

type NullInt64 struct {
    sql.NullInt64
}

NullInt64 is an alias for sql.NullInt64 data type

func NewNullInt64 Uses

func NewNullInt64(s int64) NullInt64

NewNullInt64 returns a sql.NullInt64 for JSON parsing

func (*NullInt64) MarshalJSON Uses

func (ni *NullInt64) MarshalJSON() ([]byte, error)

MarshalJSON for NullInt64

func (*NullInt64) UnmarshalJSON Uses

func (nf *NullInt64) UnmarshalJSON(b []byte) error

Unmarshaler for NullInt64

type NullString Uses

type NullString struct {
    sql.NullString
}

NullString is an alias for sql.NullString data type

func NewNullString Uses

func NewNullString(s string) NullString

NewNullString returns a sql.NullString for JSON parsing

func (*NullString) MarshalJSON Uses

func (ns *NullString) MarshalJSON() ([]byte, error)

MarshalJSON for NullString

func (*NullString) UnmarshalJSON Uses

func (nf *NullString) UnmarshalJSON(b []byte) error

Unmarshaler for NullString

type Plugin Uses

type Plugin struct {
    Name        string
    Description string
}

type PluginActions Uses

type PluginActions interface {
    GetInfo() *Info
    OnLoad() error
}

type PluginInfo Uses

type PluginInfo struct {
    Info   *Info
    Routes []*PluginRoute
}

type PluginJSON Uses

type PluginJSON struct {
    Name        string `json:"name"`
    Description string `json:"description"`
    Repo        string `json:"repo"`
    Author      string `json:"author"`
    Namespace   string `json:"namespace"`
}

type PluginObject Uses

type PluginObject struct {
    Pluginer
}

type PluginRepos Uses

type PluginRepos struct {
    Plugins []PluginJSON
}

type PluginRoute Uses

type PluginRoute struct {
    Url    string
    Method string
    Func   http.HandlerFunc
}

type PluginRouting Uses

type PluginRouting struct {
    URL     string
    Method  string
    Handler func(http.ResponseWriter, *http.Request)
}

type Pluginer Uses

type Pluginer interface {
    Select() *Plugin
}

type Router Uses

type Router interface {
    Routes() []*PluginRoute
    AddRoute(string, string, http.HandlerFunc) error
}

type Service Uses

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 Uses

func (s *Service) BeforeCreate() (err error)

BeforeCreate for Service will set CreatedAt to UTC

func (*Service) Close Uses

func (s *Service) Close()

Close will stop the go routine that is checking if service is online or not

func (*Service) IsRunning Uses

func (s *Service) IsRunning() bool

IsRunning returns true if the service go routine is running

func (*Service) Start Uses

func (s *Service) Start()

Start will create a channel for the service checking go routine

type ServiceInterface Uses

type ServiceInterface interface {
    Select() *Service
    CheckQueue(bool)
    Check(bool)
    Create(bool) (int64, error)
    Update(bool) error
    Delete() error
}

type User Uses

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 Uses

func (u *User) BeforeCreate() (err error)

BeforeCreate for User will set CreatedAt to UTC

type UserInterface Uses

type UserInterface interface {
    Create() (int64, error)
    Update() error
    Delete() error
}

UserInterface interfaces the database functions

Package types imports 5 packages (graph) and is imported by 14 packages. Updated 2019-07-20. Refresh now. Tools for package owners.