database

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatabaseName = "InfluxDB"
)

Variables

View Source
var (
	MeanResponseCount = 5 //Default number of response times to calcuate mean response time
	ErrorCount        = 1 //Default number of errors should occur to send notification

	ErrResposeCode   = errors.New("Response code do not Match")
	ErrTimeout       = errors.New("Request Time out Error")
	ErrCreateRequest = errors.New("Invalid Request Config.Not able to create request")
	ErrDoRequest     = errors.New("Request failed")
)

Functions

func AddErrorInfo

func AddErrorInfo(errorInfo ErrorInfo)

This function is called by requests package when a reuquest fails Error Information is inserted to all the registered databases

func AddNew

func AddNew(databaseTypes DatabaseTypes)

Add database to the database List

func AddRequestInfo

func AddRequestInfo(requestInfo RequestInfo)

This function is called by requests package when request has been successfully performed Request data is inserted to all the registered databases

func EnableLogging

func EnableLogging(fileName string)

func Initialize

func Initialize(ids map[int]int64, mMeanResponseCount int, mErrorCount int)

Intialize responseMean app and counts

Types

type Database

type Database interface {
	Initialize() error
	GetDatabaseName() string
	AddRequestInfo(requestInfo RequestInfo) error
	AddErrorInfo(errorInfo ErrorInfo) error
}

type DatabaseTypes

type DatabaseTypes struct {
	InfluxDb InfluxDb `json:"influxDb"`
}

type ErrorInfo

type ErrorInfo struct {
	Id           int
	Url          string
	RequestType  string
	ResponseCode int
	ResponseBody string
	Reason       error
	OtherInfo    string
}

type InfluxDb

type InfluxDb struct {
	Host         string `json:"host"`
	Port         int    `json:"port"`
	DatabaseName string `json:"databaseName"`
	Username     string `json:"username"`
	Password     string `json:"password"`
}

func (InfluxDb) AddErrorInfo

func (influxDb InfluxDb) AddErrorInfo(errorInfo ErrorInfo) error

Add Error information to database

func (InfluxDb) AddRequestInfo

func (influxDb InfluxDb) AddRequestInfo(requestInfo RequestInfo) error

Add request information to database

func (InfluxDb) GetDatabaseName

func (influxDb InfluxDb) GetDatabaseName() string

Return database name

func (InfluxDb) GetMeanResponseTime

func (influxDb InfluxDb) GetMeanResponseTime(Url string, span int) (float64, error)

Returns mean response time of url in given time .Currentlt not used

func (InfluxDb) Initialize

func (influxDb InfluxDb) Initialize() error

Intiliaze influx db

type RequestInfo

type RequestInfo struct {
	Id                   int
	Url                  string
	RequestType          string
	ResponseCode         int
	ResponseTime         int64
	ExpectedResponseTime int64
}

Jump to

Keyboard shortcuts

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