暂存
This commit is contained in:
39
ragflow/system.go
Normal file
39
ragflow/system.go
Normal file
@@ -0,0 +1,39 @@
|
||||
package ragflow
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// System 系统管理
|
||||
// 参考: https://ragflow.com.cn/docs/dev/http_api_reference#系统
|
||||
|
||||
// HealthStatus 健康状态
|
||||
type HealthStatus struct {
|
||||
DB string `json:"db"` // "ok" 或 "nok"
|
||||
Redis string `json:"redis"` // "ok" 或 "nok"
|
||||
DocEngine string `json:"doc_engine"` // "ok" 或 "nok"
|
||||
Storage string `json:"storage"` // "ok" 或 "nok"
|
||||
Status string `json:"status"` // 整体状态: "ok" 或 "nok"
|
||||
Meta map[string]interface{} `json:"_meta,omitempty"` // 详细错误信息
|
||||
}
|
||||
|
||||
// CheckHealth 检查系统健康状况
|
||||
// GET /v1/system/healthz
|
||||
func (c *Client) CheckHealth(ctx context.Context) (*HealthStatus, error) {
|
||||
var status HealthStatus
|
||||
if err := c.request(ctx, "GET", "/v1/system/healthz", nil, &status); err != nil {
|
||||
return nil, fmt.Errorf("check health failed: %w", err)
|
||||
}
|
||||
return &status, nil
|
||||
}
|
||||
|
||||
// IsHealthy 检查系统是否健康
|
||||
func (c *Client) IsHealthy(ctx context.Context) (bool, error) {
|
||||
status, err := c.CheckHealth(ctx)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
return status.Status == "ok", nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user