package console import "context" func (s *Server) registerClaimWorkers() { s.claimWorkers = map[string]func(context.Context){} for name, h := range map[string]func(context.Context){ "StartHostReports": s.StartHostReports, "StartAlertWatcher": s.StartAlertWatcher, "StartGeoipJobs": s.StartGeoipJobs, "StartClaimRecoveryPass": s.StartClaimRecoveryPass, "StartEconomicsPass": s.StartEconomicsPass, "StartInfraPass": s.StartInfraPass, "StartScanPass": s.StartScanPass, "StartScanDrain": s.StartScanDrain, "StartExpiryPass": s.StartExpiryPass, "StartPlanLimitsPass": s.StartPlanLimitsPass, "StartPlanGracePass": s.StartPlanGracePass, "PublishPlansMarker": s.PublishPlansMarker, "StartRunSweep": s.StartRunSweep, "StartSeedsPass": s.StartSeedsPass, "StartRelay": s.StartRelay, "StartMailEventPush": s.StartMailEventPush, "StartDoorKeyResign": s.StartDoorKeyResign, "ReportApexSquats": s.ReportApexSquats, "LogPlacementDiscrepancies": s.LogPlacementDiscrepancies, "PublishMovesConsole": s.publishMovesConsoleWorker, } { e := claimEntry{Kind: "worker", Pattern: name, Handler: claimHandlerName(h)} s.claimEntries.add(e) if !s.cfg.HostClaim { s.claimWorkers[name] = h continue } s.claimWorkers[name] = func(ctx context.Context) { h(context.WithValue(ctx, claimEntryKey{}, e)) } } } // publishMovesConsoleWorker is PublishMovesConsole as a recorded worker. The // method logs its own failure (it is best-effort and the console serves // regardless), so the worker drops the returned error. It is a no-op with the // moves switch off. func (s *Server) publishMovesConsoleWorker(ctx context.Context) { _ = s.PublishMovesConsole(ctx) } func (s *Server) RunClaimWorker(ctx context.Context, name string) { h, ok := s.claimWorkers[name] if !ok { panic("unregistered console worker: " + name) } h(ctx) }