RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.
Go agent-harnessagent-native-databaseagentic-aiagentic-retrievalagentic-searchaiai-agentscontext-enginecontext-engineeringcontext-managementharness-engineeringknowledge-compilationragretrieval-augmented-generationretrieval-harnesssearch-harness
Go admin: update heartbeat (#20275)
Jin Hai5271bb0f37ab
diff --git a/internal/admin/handler.go b/internal/admin/handler.goindex ef81ecd76d..436130753f 100644--- a/internal/admin/handler.go+++ b/internal/admin/handler.go@@ -1175,8 +1175,8 @@ func (h *Handler) Reports(c *gin.Context) {}// Handle the heartbeat- errCode, message := h.service.HandleHeartbeat(&req)- common.ErrorWithCode(c, errCode, message)+ errCode, data, message := h.service.HandleHeartbeat(&req)+ common.ResponseWithCodeData(c, errCode, data, message)}func (h *Handler) ListAllModels(c *gin.Context) {diff --git a/internal/admin/service.go b/internal/admin/service.goindex a1c6a334d0..1f41c5fc48 100644--- a/internal/admin/service.go+++ b/internal/admin/service.go@@ -1455,7 +1455,7 @@ func (s *Service) TestSandboxConnection(ctx context.Context, providerType stringvar heartBeatCount int64 = 0// HandleHeartbeat handle heartbeat-func (s *Service) HandleHeartbeat(message *common.BaseMessage) (common.ErrorCode, string) {+func (s *Service) HandleHeartbeat(message *common.BaseMessage) (common.ErrorCode, map[string]interface{}, string) {heartBeatCount++status := &common.BaseMessage{diff --git a/internal/admin/service_ee.go b/internal/admin/service_ee.goindex b127d1ed5f..45ed04111d 100644--- a/internal/admin/service_ee.go+++ b/internal/admin/service_ee.go@@ -30,8 +30,11 @@ import ("gorm.io/gorm")-func UpdateServer(serverName string, status *common.BaseMessage) (common.ErrorCode, string) {- GlobalServerStore.UpdateServerInfo(serverName, status)+func UpdateServer(serverName string, status *common.BaseMessage) (common.ErrorCode, map[string]interface{}, string) {+ err := GlobalServerStore.UpdateServerInfo(serverName, status)+ if err != nil {+ return common.CodeErrorServerStatus, nil, err.Error()+ }return CheckLicense()}@@ -1241,8 +1244,12 @@ func (s *Service) RemoveIngestionTasksByCondition(ctx context.Context, tasks []sreturn []map[string]interface{}{element}, nil}-func CheckLicense() (common.ErrorCode, string) {- return common.CodeLicenseValid, ""+func CheckClientStatus(serverName string, status *common.BaseMessage) error {+ return nil+}++func CheckLicense() (common.ErrorCode, map[string]interface{}, string) {+ return common.CodeLicenseValid, map[string]interface{}{}, ""}// DownloadSensitiveWords download sensitive wordsdiff --git a/internal/admin/state.go b/internal/admin/state.goindex 45c08397ae..1a5d0e41c2 100644--- a/internal/admin/state.go+++ b/internal/admin/state.go@@ -36,29 +36,21 @@ var GlobalServerStore = &ServerStore{}// UpdateServerInfo updates or adds a server status-func (s *ServerStore) UpdateServerInfo(serverName string, status *common.BaseMessage) {+func (s *ServerStore) UpdateServerInfo(serverName string, status *common.BaseMessage) error {- //switch serviceType {- //case "meta_data":- // return s.getMySQLStatus(name)+ s.mu.Lock()+ defer s.mu.Unlock()switch status.ServerType {case common.ServerTypeAPI:- s.mu.Lock()- defer s.mu.Unlock()s.servers[serverName] = status- returncase common.ServerTypeIngestion:- s.mu.Lock()- defer s.mu.Unlock()s.servers[serverName] = status- returncase common.ServerTypeFileSyncer:- s.mu.Lock()- defer s.mu.Unlock()s.servers[serverName] = status- return}++ return CheckClientStatus(serverName, status)}// GetServerInfo gets a single server statusdiff --git a/internal/common/error_code.go b/internal/common/error_code.goindex 9c7a8d60cf..ec56f9ae67 100644--- a/internal/common/error_code.go+++ b/internal/common/error_code.go@@ -44,6 +44,7 @@ const (CodeLicenseNotFound ErrorCode = 325CodeLicenseUnexpectedError ErrorCode = 326CodeLicenseNotValidYet ErrorCode = 327+ CodeErrorServerStatus ErrorCode = 330CodeBadRequest ErrorCode = 400CodeUnauthorized ErrorCode = 401CodeForbidden ErrorCode = 403diff --git a/internal/service/admin_client.go b/internal/service/admin_client.goindex 1a19413929..5d7ee839de 100644--- a/internal/service/admin_client.go+++ b/internal/service/admin_client.go@@ -157,6 +157,13 @@ func (h *AdminClient) SendHeartbeat() error {}licenseStatusCode = responseCode+ responseData := responseBody["data"]+ err = h.UpdateClient(responseData)+ if err != nil {+ common.Error("fail to update client info", err)+ return err+ }+common.Debug("Heartbeat sent successfully",zap.String("server_id", h.serverName),zap.String("server_type", string(h.serverType)),diff --git a/internal/service/admin_client_ee.go b/internal/service/admin_client_ee.goindex d2683d9bd8..f251ee0a1e 100644--- a/internal/service/admin_client_ee.go+++ b/internal/service/admin_client_ee.go@@ -18,3 +18,5 @@ package servicefunc (h *AdminClient) InitHTTPClientEE() error {return nil}++func (h *AdminClient) UpdateClient(clientInfo interface{}) error { return nil }