utils

package
v0.0.0-...-ae485d8 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	APIType500          = "500"
	APIType50x          = "50x"
	APITypeTimeout      = "timeout"
	APITypeAssertFailed = "assert"
)
View Source
const (
	AllowAccessEndpointType = 1
	LimitAccessEndpointType = 0
)

Variables

View Source
var Config = struct {
	Name                         string `default:"api-monitor"`
	MonitorName                  string `default:"api-monitor"`
	IsDebug                      bool
	MonitoringExpression         string
	APIMonitorEnabled            bool `default:"true"`
	PingAPIMonitorEnabled        bool
	GlobalDatabase               MySQLDB
	APIConfigDatabase            MySQLDB
	APIConfigDatabaseTablePrefix string
	Timeout                      struct {
		Timeout               time.Duration `default:"15"`
		TLSHandshakeTimeout   time.Duration `default:"15"`
		ResponseHeaderTimeout time.Duration `default:"15"`
		ExpectContinueTimeout time.Duration `default:"1"`
	}
	SourceFormat struct {
		Ping     string `default:"mysql"`
		API      string `default:"mysql"`
		Endpoint string `default:"mysql"`
	}
	SenderConfig SenderConfig
}{}

config

View Source
var UTF8BOM = []byte{239, 187, 191}

Functions

func AddDatabaseConfig

func AddDatabaseConfig(value MySQLDB, configs map[string]string)

add database config

func CastType

func CastType(value, valueType string) interface{}

cast type

func ConfigLocalFileSystemLogger

func ConfigLocalFileSystemLogger(logPath string, logFileName string, maxAge time.Duration, rotationTime time.Duration)

custom logs

func GetAllDatabaseConfigs

func GetAllDatabaseConfigs() map[string]string

get all database configs

func GetMonitoringExpression

func GetMonitoringExpression() string

TODO check cron expression

func HasBOM

func HasBOM(in []byte) bool

func InitConfig

func InitConfig(files string)

init config, example: config.example

func StripBOM

func StripBOM(in []byte) []byte

Types

type MySQLDB

type MySQLDB struct {
	Read     MySQLDSN
	Write    MySQLDSN
	Timezone string
}

mysql db

type MySQLDSN

type MySQLDSN struct {
	Name string
	DSN  string
}

dsn

type SenderConfig

type SenderConfig struct {
	BearyChat struct {
		IsEnabled      bool
		GroupEndpoint  string
		UnSupportTypes map[string]int
	}
	Slack struct {
		IsEnabled      bool
		RobotToken     string
		Channel        string
		UnSupportTypes map[string]int
	}
	Log struct {
		IsEnabled bool
	}
}

sender config

Jump to

Keyboard shortcuts

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