feat: publish standalone worker
Separate worker packaging and service lifecycle from the control plane.
Этот коммит содержится в:
52
checks/llmhttp/result.go
Обычный файл
52
checks/llmhttp/result.go
Обычный файл
@@ -0,0 +1,52 @@
|
||||
package llmhttp
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"rsgit.ru/rsmon/rsmon/app/models"
|
||||
"rsgit.ru/rsmon/rsmon/internal/checkresult"
|
||||
)
|
||||
|
||||
// Result is a result of an LLM HTTP health check
|
||||
type Result struct {
|
||||
checkresult.CheckResult
|
||||
|
||||
// Captured data
|
||||
HTML string `json:"html"` // HTML content
|
||||
URL string `json:"url"` // Final URL after redirects
|
||||
StatusCode int `json:"status_code"` // HTTP status code
|
||||
Title string `json:"title"` // Page title (extracted from HTML)
|
||||
ContentLength int64 `json:"content_length"` // Size of response body
|
||||
ContentType string `json:"content_type"` // Content-Type header
|
||||
|
||||
// LLM analysis
|
||||
LLMResponse string `json:"llm_response"` // Full LLM response
|
||||
LLMVerdict string `json:"llm_verdict"` // "normal", "error", "warning"
|
||||
LLMReasoning string `json:"llm_reasoning"` // LLM's explanation
|
||||
|
||||
// Metadata
|
||||
CheckID uint `json:"check_id"` // For database reference
|
||||
}
|
||||
|
||||
// InfluxTags provides functionality.
|
||||
func (r *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"] = r.State
|
||||
ret["code"] = strconv.Itoa(r.StatusCode)
|
||||
if r.Error != nil {
|
||||
ret["error"] = r.Error.Error()
|
||||
}
|
||||
ret["warnings"] = strings.Join(r.Warnings, ",")
|
||||
return ret
|
||||
}
|
||||
|
||||
// InfluxFields provides functionality.
|
||||
func (r *Result) InfluxFields() map[string]interface{} {
|
||||
ret := make(map[string]interface{}, 0)
|
||||
ret["took"] = int64(r.Duration / time.Millisecond)
|
||||
|
||||
return ret
|
||||
}
|
||||
Ссылка в новой задаче
Block a user