From 51b44519354e44c377da0f24bdd356f031d70557 Mon Sep 17 00:00:00 2001 From: xiaohan Date: Tue, 10 Dec 2024 22:48:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9A=B4=E6=BC=8F=E5=87=BA=E6=9D=A5M,=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E7=9F=A5=E9=81=93=E5=93=AA=E4=BA=9B=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=98=AF=E6=B3=A8=E5=86=8C=E6=88=90=E5=8A=9F=EF=BC=8C=E6=96=B9?= =?UTF-8?q?=E4=BE=BF=E7=BB=B4=E6=8A=A4=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- periodic_task_manager.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/periodic_task_manager.go b/periodic_task_manager.go index 28f9f4e..80e223e 100644 --- a/periodic_task_manager.go +++ b/periodic_task_manager.go @@ -22,7 +22,7 @@ type PeriodicTaskManager struct { syncInterval time.Duration done chan (struct{}) wg sync.WaitGroup - m map[string]struct{} // map[hash]entryID + M map[string]struct{} // map[hash]entryID } type PeriodicTaskManagerOpts struct { @@ -69,7 +69,7 @@ func NewPeriodicTaskManager(opts PeriodicTaskManagerOpts) (*PeriodicTaskManager, p: opts.PeriodicTaskConfigProvider, syncInterval: syncInterval, done: make(chan struct{}), - m: make(map[string]struct{}), + M: make(map[string]struct{}), }, nil } @@ -188,7 +188,7 @@ func (mgr *PeriodicTaskManager) add(configs []*PeriodicTaskConfig) { c.Cronspec, c.Task.Type(), err) continue } - mgr.m[entryID] = struct{}{} // ? m[string]struct{} + mgr.M[entryID] = struct{}{} // m[string]struct{} mgr.s.logger.Infof("Successfully registered periodic task: cronspec=%q task=%q, entryID=%s", c.Cronspec, c.Task.Type(), entryID) } @@ -200,7 +200,7 @@ func (mgr *PeriodicTaskManager) remove(removed map[string]struct{}) { mgr.s.logger.Errorf("Failed to unregister periodic task: %v", err) continue } - delete(mgr.m, entryID) + delete(mgr.M, entryID) mgr.s.logger.Infof("Successfully unregistered periodic task: entryID=%s", entryID) } } @@ -232,7 +232,7 @@ func (mgr *PeriodicTaskManager) diffRemoved(configs []*PeriodicTaskConfig) map[s newConfigs[c.ID] = struct{}{} // empty value since we don't have entryID yet } removed := make(map[string]struct{}) - for k, _ := range mgr.m { + for k, _ := range mgr.M { // test whether existing config is present in the incoming configs if _, found := newConfigs[k]; !found { removed[k] = struct{}{} @@ -246,7 +246,7 @@ func (mgr *PeriodicTaskManager) diffRemoved(configs []*PeriodicTaskConfig) map[s func (mgr *PeriodicTaskManager) diffAdded(configs []*PeriodicTaskConfig) []*PeriodicTaskConfig { var added []*PeriodicTaskConfig for _, c := range configs { - if _, found := mgr.m[c.ID]; !found { + if _, found := mgr.M[c.ID]; !found { added = append(added, c) } }