(ctx context.Context, cfg *config.Config, report homeplugins.SyncReport)
| 46 | } |
| 47 | |
| 48 | func (s *Service) reportHomePluginStatus(ctx context.Context, cfg *config.Config, report homeplugins.SyncReport) { |
| 49 | if s == nil || cfg == nil { |
| 50 | return |
| 51 | } |
| 52 | if s.homeClient == nil { |
| 53 | log.Warn("failed to report home plugin status: home client is unavailable") |
| 54 | return |
| 55 | } |
| 56 | nodeID := strings.TrimSpace(cfg.Home.NodeID) |
| 57 | if nodeID == "" { |
| 58 | log.Warn("failed to report home plugin status: node id is empty") |
| 59 | return |
| 60 | } |
| 61 | report.NodeID = nodeID |
| 62 | report.UpdatedAt = time.Now().UTC() |
| 63 | raw, errMarshal := json.Marshal(report) |
| 64 | if errMarshal != nil { |
| 65 | log.Warnf("failed to marshal home plugin status: %v", errMarshal) |
| 66 | return |
| 67 | } |
| 68 | if ctx == nil { |
| 69 | ctx = context.Background() |
| 70 | } |
| 71 | reportCtx, cancel := context.WithTimeout(ctx, homePluginStatusReportTimeout) |
| 72 | defer cancel() |
| 73 | if errReport := s.homeClient.RPushPluginStatus(reportCtx, raw); errReport != nil { |
| 74 | log.Warnf("failed to report home plugin status: %v", errReport) |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | func (s *Service) processHomePluginTasks(ctx context.Context, cfg *config.Config) { |
| 79 | if s == nil || cfg == nil || !cfg.Home.Enabled || s.homeClient == nil { |
no test coverage detected