()
| 78 | } |
| 79 | |
| 80 | func start() error { |
| 81 | // Create fresh worker managers on Start() to enable clean restarts after Stop(). |
| 82 | // (after module.Manager().Stop() has been called, all workers are stopped and cannot be reused) |
| 83 | module.selfcheckWorkerMgr = module.Manager().NewWorkerMgr("compatibility self-check", selfcheckTaskFunc, nil) |
| 84 | module.cleanNotifyThresholdWorkerMgr = module.Manager().NewWorkerMgr("clean notify thresholds", cleanNotifyThreshold, nil) |
| 85 | |
| 86 | startNotify() |
| 87 | |
| 88 | selfcheckNetworkChangedFlag.Refresh() |
| 89 | |
| 90 | // Schedule periodic self-checks. |
| 91 | module.selfcheckWorkerMgr.Repeat(5 * time.Minute).Delay(selfcheckTaskRetryAfter) |
| 92 | module.cleanNotifyThresholdWorkerMgr.Repeat(1 * time.Hour) |
| 93 | |
| 94 | // Add network change callback to trigger immediate self-check. |
| 95 | module.instance.NetEnv().EventNetworkChange.AddCallback("trigger compat self-check", func(_ *mgr.WorkerCtx, _ struct{}) (bool, error) { |
| 96 | module.selfcheckWorkerMgr.Delay(selfcheckTaskRetryAfter) |
| 97 | return false, nil |
| 98 | }) |
| 99 | return nil |
| 100 | } |
| 101 | |
| 102 | func stop() error { |
| 103 | resetSelfCheckState() |
no test coverage detected