feat: expose monitoring pf health detail

This commit is contained in:
Grendgi
2026-06-17 15:59:53 +03:00
parent ccd56165c7
commit f73c9fba5f
3 changed files with 136 additions and 0 deletions

View File

@@ -34,6 +34,10 @@ type CheckResult struct {
Changes int `json:"changes"`
}
type HealthResult struct {
Status string `json:"status"`
}
type Suggestion struct {
Source string `json:"source"`
ExternalID string `json:"external_id"`
@@ -104,6 +108,17 @@ func (w *Worker) Suggest(ctx context.Context, projectID int64) (*SuggestionsResp
return &out, nil
}
func (w *Worker) Health(ctx context.Context) error {
var out HealthResult
if err := w.call(ctx, "health", map[string]any{}, &out); err != nil {
return err
}
if out.Status != "ok" {
return fmt.Errorf("worker status=%s", out.Status)
}
return nil
}
func (w *Worker) call(ctx context.Context, command string, payload any, out any) error {
ctx, cancel := context.WithTimeout(ctx, 15*time.Minute)
defer cancel()