From 93b829c35d7f204a6becccee296437c838a8446f Mon Sep 17 00:00:00 2001 From: Michael Freeman Date: Sun, 19 Jan 2025 20:29:28 -0600 Subject: [PATCH] fixing linter issues --- pkg/cloud/server.go | 29 ++++++++++++++++++++++------- web/package.json | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pkg/cloud/server.go b/pkg/cloud/server.go index f1db964..926a884 100644 --- a/pkg/cloud/server.go +++ b/pkg/cloud/server.go @@ -259,7 +259,7 @@ func (s *Server) processStatusReport( apiStatus := s.createNodeStatus(req, now) - s.processServices(req.PollerId, apiStatus, now) + s.processServices(req.PollerId, apiStatus, req.Services, now) if err := s.updateNodeState(ctx, req.PollerId, apiStatus, currentState, now); err != nil { return nil, err @@ -277,17 +277,32 @@ func (*Server) createNodeStatus(req *proto.PollerStatusRequest, now time.Time) * } } -func (s *Server) processServices(pollerID string, apiStatus *api.NodeStatus, now time.Time) { - for _, svc := range apiStatus.Services { +func (s *Server) processServices(pollerID string, apiStatus *api.NodeStatus, services []*proto.ServiceStatus, now time.Time) { + for _, svc := range services { + apiService := api.ServiceStatus{ + Name: svc.ServiceName, + Type: svc.ServiceType, + Available: svc.Available, + Message: svc.Message, + } + if !svc.Available { apiStatus.IsHealthy = false } - if err := s.handleService(pollerID, &svc, now); err != nil { - log.Printf("Error handling service %s: %v", svc.Name, err) + // Process JSON details if available + if svc.Message != "" { + var details json.RawMessage + if err := json.Unmarshal([]byte(svc.Message), &details); err == nil { + apiService.Details = details + } + } - continue + if err := s.handleService(pollerID, &apiService, now); err != nil { + log.Printf("Error handling service %s: %v", svc.ServiceName, err) } + + apiStatus.Services = append(apiStatus.Services, apiService) } } @@ -613,7 +628,7 @@ func (s *Server) sendStartupNotification(ctx context.Context) { Timestamp: time.Now().UTC().Format(time.RFC3339), NodeID: "cloud", Details: map[string]any{ - "version": "1.0.1", // TODO: query version from DB + "version": "1.0.2", // TODO: query version from DB "hostname": getHostname(), "pid": os.Getpid(), "total_nodes": nodeCount, diff --git a/web/package.json b/web/package.json index 20ac706..ba8757f 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "serviceradar-web", - "version": "1.0.1", + "version": "1.0.2", "private": true, "type": "module", "dependencies": {