diff --git a/cluster.go b/cluster.go index f4de751..fc81762 100644 --- a/cluster.go +++ b/cluster.go @@ -104,19 +104,19 @@ func (c *cluster) AddTimer(ctx context.Context, uniqueKey string, spaceTime time }) execTime[uniqueKey] = nextTime n, _ := json.Marshal(execTime) - fmt.Println("execTime:", execTime, string(n)) + // fmt.Println("execTime:", execTime, string(n)) p.Set(ctx, c.nextKey, string(n), 0) _, err := p.Exec(ctx) - fmt.Println("添加", err) + // fmt.Println("添加", err) return err } // 计算下一次执行的时间 func (c *cluster) computeTime() { - log.Println("begin computer") + // log.Println("begin computer") ctx, cancel := context.WithCancel(c.ctx) defer cancel() @@ -174,7 +174,8 @@ func (c *cluster) computeTime() { // log.Println("B", string(b)) _, err := p.Exec(ctx) - fmt.Println(err) + _ = err + // fmt.Println(err) } // 递归遍历获取执行时间 diff --git a/cmd/main.go b/cmd/main.go index 3f685ba..4caa9d1 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -89,9 +89,9 @@ func re() { } func aa(ctx context.Context) bool { - fmt.Println(time.Now().Format(time.RFC3339)) - fmt.Println("gggggggggggggggggggggggggggg") + // fmt.Println(time.Now().Format(time.RFC3339)) + // fmt.Println("gggggggggggggggggggggggggggg") a, err := timer.GetExtendParams(ctx) - fmt.Printf("%+v %+v", a, err) + fmt.Printf("%+v %+v \n\n", a, err) return true } diff --git a/example_test.go b/example_test.go index dc54c3b..7581bc0 100644 --- a/example_test.go +++ b/example_test.go @@ -31,7 +31,7 @@ func TestMain(m *testing.M) { fmt.Println("redis init error") return } - Redis = client + // Redis = client } diff --git a/lockx/lockx.go b/lockx/lockx.go index 5c38ab4..74214d9 100644 --- a/lockx/lockx.go +++ b/lockx/lockx.go @@ -67,7 +67,9 @@ func (g *globalLock) Unlock() bool { // 刷新锁 func (g *globalLock) Refresh() { go func() { - ctx = context.WithTimeout(g.ctx, time.Second*30) + ctx,cancel := context.WithTimeout(g.ctx, time.Second*30) + defer cancel() + t := time.NewTicker(time.Second) for { select {