types

package
v0.79.95 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2018 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package types contains all of the structs for objects in Statup including services, hits, failures, Core, and others.

More info on: https://github.com/hunterlong/statup

Index

Constants

View Source
const (
	TIME_NANO     = "2006-01-02T15:04:05Z"
	TIME          = "2006-01-02 15:04:05"
	POSTGRES_TIME = "2006-01-02 15:04"
	CHART_TIME    = "2006-01-02T15:04:05.999999-07:00"
	TIME_DAY      = "2006-01-02"
)

Variables

View Source
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 Asseter added in v0.79.1

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

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:"-"`
	Hits        []*CheckinHit `gorm:"-" json:"hits"`
	Failures    []*Failure    `gorm:"-" json:"failures"`
}

Checkin struct will allow an application to send a recurring HTTP GET to confirm a service is online

func (*Checkin) Close added in v0.79.1

func (s *Checkin) Close()

Close will stop the checkin routine

func (*Checkin) IsRunning added in v0.79.1

func (s *Checkin) IsRunning() bool

IsRunning returns true if the checkin go routine is running

func (*Checkin) Start added in v0.79.1

func (s *Checkin) Start()

Start will create a channel for the checkin checking go 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:"checkin"`
	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

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"`
	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 Statup. 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 added in v0.79.1

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

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

func (FailSort) Len added in v0.79.9

func (s FailSort) Len() int

func (FailSort) Less added in v0.79.9

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

func (FailSort) Swap added in v0.79.9

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

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"`
	Service   int64     `gorm:"index;column:service" 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.

type FailureInterface added in v0.79.1

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 Hit added in v0.27.7

type Hit struct {
	Id        int64     `gorm:"primary_key;column:id"`
	Service   int64     `gorm:"column:service"`
	Latency   float64   `gorm:"column:latency"`
	PingTime  float64   `gorm:"column:ping_time"`
	CreatedAt time.Time `gorm:"column:created_at"`
}

Hit struct is a 'successful' ping or web response entry for a service.

type Info added in v0.79.1

type Info struct {
	Name        string
	Description string
	Form        string
}

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

type NullBool added in v0.79.4

type NullBool struct {
	sql.NullBool
}

NullBool is an alias for sql.NullBool data type

func NewNullBool added in v0.79.4

func NewNullBool(s bool) NullBool

NewNullBool returns a sql.NullBool for JSON parsing

func (*NullBool) MarshalJSON added in v0.79.4

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

MarshalJSON for NullBool

func (*NullBool) UnmarshalJSON added in v0.79.4

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

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

type NullInt64 struct {
	sql.NullInt64
}

NullInt64 is an alias for sql.NullInt64 data type

func NewNullInt64 added in v0.79.4

func NewNullInt64(s int64) NullInt64

NewNullInt64 returns a sql.NullInt64 for JSON parsing

func (*NullInt64) MarshalJSON added in v0.79.4

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

MarshalJSON for NullInt64

func (*NullInt64) UnmarshalJSON added in v0.79.4

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

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 Plugin added in v0.79.1

type Plugin struct {
	Name        string
	Description string
}

type PluginActions added in v0.79.1

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

type PluginInfo added in v0.79.1

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

type PluginJSON added in v0.27.7

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 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 PluginRouting struct {
	URL     string
	Method  string
	Handler func(http.ResponseWriter, *http.Request)
}

type Pluginer added in v0.79.1

type Pluginer interface {
	Select() *Plugin
}

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:false;column:allow_notifications" json:"allow_notifications"`
	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_online"`
	Failures           []FailureInterface `gorm:"-" json:"failures,omitempty"`
}

Service is the main struct for Services

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

func (*Service) IsRunning added in v0.79.1

func (s *Service) IsRunning() bool

IsRunning returns true if the service go routine is running

func (*Service) Start added in v0.79.1

func (s *Service) Start()

Start will create a channel for the service checking go routine

type ServiceInterface added in v0.79.1

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

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

type UserInterface added in v0.79.1

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

UserInterface interfaces the database functions

Jump to

Keyboard shortcuts

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