types

package
v0.0.0-...-5073c34 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 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"
	TIME_DAY  = "2006-01-02"
)

Variables

View Source
var (
	NOW = func() time.Time { return time.Now() }()
)

Functions

This section is empty.

Types

type AllNotifiers

type AllNotifiers interface{}

AllNotifiers contains all the Notifiers loaded

type Asseter

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

type Checkin

type Checkin struct {
	Id          int64     `gorm:"primary_key;column:id"`
	ServiceId   int64     `gorm:"index;column:service"`
	Name        string    `gorm:"column:name"`
	Interval    int64     `gorm:"column:check_interval"`
	GracePeriod int64     `gorm:"column:grace_period"`
	ApiKey      string    `gorm:"column: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:"-"`
}

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

func (*Checkin) Close

func (s *Checkin) Close()

Close will stop the checkin routine

func (*Checkin) IsRunning

func (s *Checkin) IsRunning() bool

IsRunning returns true if the checkin go routine is running

func (*Checkin) Start

func (s *Checkin) Start()

Start will create a channel for the checkin checking go routine

type CheckinHit

type CheckinHit struct {
	Id        int64     `gorm:"primary_key;column:id"`
	Checkin   int64     `gorm:"index;column:checkin"`
	From      string    `gorm:"column:from_location"`
	CreatedAt time.Time `gorm:"column:created_at" json:"created_at"`
}

CheckinHit is a successful response from a Checkin

type Core

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:"services,omitempty"`
	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

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

type DbConfig

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"`
}

DbConfig struct is used for the database connection and creates the 'config.yml' file

type Failure

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

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

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

type Info struct {
	Name        string
	Description string
	Form        string
}

type Message

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 time.Duration `gorm:"column:notify_before" json:"notify_before"`
	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

type NullBool struct {
	sql.NullBool
}

NullBool is an alias for sql.NullBool data type

func NewNullBool

func NewNullBool(s bool) NullBool

NewNullBool returns a sql.NullBool for JSON parsing

func (*NullBool) MarshalJSON

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

MarshalJSON for NullBool

func (*NullBool) UnmarshalJSON

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

Unmarshaler for NullBool

type NullFloat64

type NullFloat64 struct {
	sql.NullFloat64
}

NullFloat64 is an alias for sql.NullFloat64 data type

func NewNullFloat64

func NewNullFloat64(s float64) NullFloat64

NewNullFloat64 returns a sql.NullFloat64 for JSON parsing

func (*NullFloat64) MarshalJSON

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

MarshalJSON for NullFloat64

func (*NullFloat64) UnmarshalJSON

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

Unmarshaler for NullFloat64

type NullInt64

type NullInt64 struct {
	sql.NullInt64
}

NullInt64 is an alias for sql.NullInt64 data type

func NewNullInt64

func NewNullInt64(s int64) NullInt64

NewNullInt64 returns a sql.NullInt64 for JSON parsing

func (*NullInt64) MarshalJSON

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

MarshalJSON for NullInt64

func (*NullInt64) UnmarshalJSON

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

Unmarshaler for NullInt64

type NullString

type NullString struct {
	sql.NullString
}

NullString is an alias for sql.NullString data type

func NewNullString

func NewNullString(s string) NullString

NewNullString returns a sql.NullString for JSON parsing

func (*NullString) MarshalJSON

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

MarshalJSON for NullString

func (*NullString) UnmarshalJSON

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

Unmarshaler for NullString

type Plugin

type Plugin struct {
	Name        string
	Description string
}

type PluginActions

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

type PluginInfo

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

type PluginJSON

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

type PluginObject struct {
	Pluginer
}

type PluginRepos

type PluginRepos struct {
	Plugins []PluginJSON
}

type PluginRoute

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

type PluginRouting

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

type Pluginer

type Pluginer interface {
	Select() *Plugin
}

type Router

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

type Service

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           []*Failure    `gorm:"-" json:"failures,omitempty"`
}

Service is the main struct for Services

func (*Service) Close

func (s *Service) Close()

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

func (*Service) IsRunning

func (s *Service) IsRunning() bool

IsRunning returns true if the service go routine is running

func (*Service) Start

func (s *Service) Start()

Start will create a channel for the service checking go routine

type ServiceInterface

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

type User

type User struct {
	Id            int64     `gorm:"primary_key;column:id" json:"id"`
	Username      string    `gorm:"type:varchar(100);unique;column:username;" json:"username"`
	Password      string    `gorm:"column:password" json:"-"`
	Email         string    `gorm:"type:varchar(100);unique;column:email" json:"-"`
	ApiKey        string    `gorm:"column:api_key" json:"api_key"`
	ApiSecret     string    `gorm:"column:api_secret" json:"-"`
	Admin         NullBool  `gorm:"column:administrator" json:"admin"`
	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

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