Skip to content

Commit

Permalink
Merge pull request #52 from mfreeman451/42-chore-linter-fixes
Browse files Browse the repository at this point in the history
fixing linter issues
  • Loading branch information
mfreeman451 authored Jan 20, 2025
2 parents 7c04724 + 93b829c commit 60f5cec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
29 changes: 22 additions & 7 deletions pkg/cloud/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serviceradar-web",
"version": "1.0.1",
"version": "1.0.2",
"private": true,
"type": "module",
"dependencies": {
Expand Down

0 comments on commit 60f5cec

Please sign in to comment.