2018-12-04 05:57:11 +00:00
|
|
|
// Statping
|
2018-08-16 06:22:20 +00:00
|
|
|
// Copyright (C) 2018. Hunter Long and the project contributors
|
|
|
|
// Written by Hunter Long <info@socialeck.com> and the project contributors
|
|
|
|
//
|
2018-12-04 04:17:29 +00:00
|
|
|
// https://github.com/hunterlong/statping
|
2018-08-16 06:22:20 +00:00
|
|
|
//
|
|
|
|
// The licenses for most software and other practical works are designed
|
|
|
|
// to take away your freedom to share and change the works. By contrast,
|
|
|
|
// the GNU General Public License is intended to guarantee your freedom to
|
|
|
|
// share and change all versions of a program--to make sure it remains free
|
|
|
|
// software for all its users.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2018-06-23 04:17:57 +00:00
|
|
|
package types
|
|
|
|
|
2018-06-30 00:57:05 +00:00
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
2018-09-10 09:01:04 +00:00
|
|
|
// Hit struct is a 'successful' ping or web response entry for a service.
|
|
|
|
type Hit struct {
|
2019-01-10 16:47:01 +00:00
|
|
|
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"`
|
2018-09-10 09:01:04 +00:00
|
|
|
}
|
|
|
|
|
2019-02-01 04:48:18 +00:00
|
|
|
// BeforeCreate for Hit will set CreatedAt to UTC
|
|
|
|
func (h *Hit) BeforeCreate() (err error) {
|
|
|
|
if h.CreatedAt.IsZero() {
|
|
|
|
h.CreatedAt = time.Now().UTC()
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2018-09-10 09:01:04 +00:00
|
|
|
// DbConfig struct is used for the database connection and creates the 'config.yml' file
|
|
|
|
type DbConfig struct {
|
|
|
|
DbConn string `yaml:"connection"`
|
|
|
|
DbHost string `yaml:"host"`
|
|
|
|
DbUser string `yaml:"user"`
|
|
|
|
DbPass string `yaml:"password"`
|
|
|
|
DbData string `yaml:"database"`
|
2018-10-11 16:53:13 +00:00
|
|
|
DbPort int64 `yaml:"port"`
|
2018-09-10 09:01:04 +00:00
|
|
|
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"`
|
2018-11-19 07:13:53 +00:00
|
|
|
LocalIP string `yaml:"-"`
|
2018-09-10 09:01:04 +00:00
|
|
|
}
|