feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
41
checks/chttp/result.go
Обычный файл
41
checks/chttp/result.go
Обычный файл
@@ -0,0 +1,41 @@
|
||||
package chttp
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/app/models"
|
||||
"rsgit.ru/rsmon/rsmon/internal/checkresult"
|
||||
)
|
||||
|
||||
// Result provides functionality.
|
||||
type Result struct {
|
||||
checkresult.CheckResult
|
||||
StatusCode int
|
||||
Status string
|
||||
Body []byte
|
||||
Headers map[string][]string
|
||||
Length int
|
||||
}
|
||||
|
||||
// InfluxFields provides functionality.
|
||||
func (hr *Result) InfluxFields() map[string]interface{} {
|
||||
ret := make(map[string]interface{}, 0)
|
||||
ret["took"] = int64(hr.Duration / time.Millisecond)
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
// InfluxTags provides functionality.
|
||||
func (hr *Result) InfluxTags(c models.Check) map[string]string { //nolint:gocritic // hugeParam: accepted for interface compatibility
|
||||
ret := make(map[string]string, 0)
|
||||
ret["check"] = strconv.FormatInt(c.ID, 10)
|
||||
ret["state"] = hr.State
|
||||
ret["code"] = strconv.Itoa(hr.StatusCode)
|
||||
if hr.Error != nil {
|
||||
ret["error"] = hr.Error.Error()
|
||||
}
|
||||
ret["warnings"] = strings.Join(hr.Warnings, ",")
|
||||
return ret
|
||||
}
|
||||
Ссылка в новой задаче
Block a user