config

package
v0.0.0-...-761af70 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(tomlConfig *TomlConfig) (db *sql.DB)

InitDB : get DB object

func SyncTaskToDB

func SyncTaskToDB(task *Task, tomlConfig *TomlConfig) (err error)

SyncTaskToDB : store task to DB

func SyncWebsitesToDB

func SyncWebsitesToDB(tomlConfig *TomlConfig) (err error)

SyncWebsitesToDB : sync websites of config.toml to db

Types

type DayStatus

type DayStatus struct {
	Date     string  `json:"date"`
	Count    int     `json:"count"`
	ErrCount int     `json:"err_count"`
	ErrRate  float32 `json:"err_rate"`
}

DayStatus : status data of day

type MysqlConfig

type MysqlConfig struct {
	DSN string
}

MysqlConfig struct

type NotificationConfig

type NotificationConfig struct {
	ShouldNotifyErrorNum int `toml:"should_notify_error_num"`
	Pagerduty            PagerdutyConfig
}

NotificationConfig struct

type PagerdutyConfig

type PagerdutyConfig struct {
	AuthToken         string `toml:"auth_token"`
	ServiceID         string `toml:"service_id"`
	From              string `toml:"from"`
	NotificationTitle string `toml:"notification_title"`
}

PagerdutyConfig struct

type Status

type Status struct {
	ID              int       `json:"id"`
	TaskID          int       `json:"task_id"`
	WebsiteID       int       `json:"website_id"`
	Position        string    `json:"position"`
	URL             string    `json:"url"`
	Label           string    `json:"label"`
	Timestamp       time.Time `json:"timestamp"`
	Filename        string    `json:"filename"`
	Elapsed         string    `json:"elapsed"`
	Method          string    `json:"method"`
	ResponseCode    string    `json:"response_code"`
	ResponseMessage string    `json:"response_message"`
	Success         string    `json:"success"`
	FailureMessage  string    `json:"failure_message"`
}

Status : Api status

func (Status) SaveToDB

func (status Status) SaveToDB(tomlConfig *TomlConfig) (err error)

SaveToDB : save status data to db

type Task

type Task struct {
	ID         int       `json:"id"`
	WebsiteID  int       `json:"website_id"`
	ExecutedAt time.Time `json:"executed_at"`
	Count      int       `json:"count"`
	ErrCount   int       `json:"err_count"`
	ErrRate    float32   `json:"err_rate"`
	File       string    `json:"file"`
}

Task : Task struct

type TomlConfig

type TomlConfig struct {
	Title        string
	Mysql        MysqlConfig
	Notification NotificationConfig
	Websites     []Website
	Datapath     string
	Rows         int
}

TomlConfig struct

func InitConfig

func InitConfig() (tomlConfig *TomlConfig, err error)

InitConfig : initialze config

type Website

type Website struct {
	ID           int         `json:"id"`
	Name         string      `json:"name"`
	URL          string      `json:"url"`
	AuthUser     string      `toml:"auth_user"`     // for 401
	AuthPassword string      `toml:"auth_password"` // for 401
	Data         []Task      `json:"data"`
	Days         []DayStatus `json:"days"`
}

Website : JMeter website

Jump to

Keyboard shortcuts

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