From 1ddb2f7bcecb7cd0302b569b8e3ed791e403b78c Mon Sep 17 00:00:00 2001 From: Ken Hibino Date: Sun, 19 Dec 2021 06:58:12 -0800 Subject: [PATCH] Use math.MaxInt64 instead of custom const --- internal/base/base.go | 6 ------ internal/rdb/rdb.go | 9 +++++---- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/internal/base/base.go b/internal/base/base.go index 91bb4f7..af0a6cc 100644 --- a/internal/base/base.go +++ b/internal/base/base.go @@ -39,12 +39,6 @@ const ( CancelChannel = "asynq:cancel" // PubSub channel ) -// Max value for int64. -// -// Use this value to check if a redis counter value reached maximum. -// As documeted in https://redis.io/commands/INCR, a string stored at a redis key is interpreted as a base-10 64 bit signed integer. -const MaxInt64 = 1<<63 - 1 - // TaskState denotes the state of a task. type TaskState int diff --git a/internal/rdb/rdb.go b/internal/rdb/rdb.go index af849b9..d0568a3 100644 --- a/internal/rdb/rdb.go +++ b/internal/rdb/rdb.go @@ -8,6 +8,7 @@ package rdb import ( "context" "fmt" + "math" "time" "github.com/go-redis/redis/v8" @@ -382,7 +383,7 @@ func (r *RDB) Done(msg *base.TaskMessage) error { argv := []interface{}{ msg.ID, expireAt.Unix(), - base.MaxInt64, + math.MaxInt64, } // Note: We cannot pass empty unique key when running this script in redis-cluster. if len(msg.UniqueKey) > 0 { @@ -493,7 +494,7 @@ func (r *RDB) MarkAsComplete(msg *base.TaskMessage) error { statsExpireAt.Unix(), now.Unix() + msg.Retention, encoded, - base.MaxInt64, + math.MaxInt64, } // Note: We cannot pass empty unique key when running this script in redis-cluster. if len(msg.UniqueKey) > 0 { @@ -735,7 +736,7 @@ func (r *RDB) Retry(msg *base.TaskMessage, processAt time.Time, errMsg string, i processAt.Unix(), expireAt.Unix(), isFailure, - base.MaxInt64, + math.MaxInt64, } return r.runScript(ctx, op, retryCmd, keys, argv...) } @@ -822,7 +823,7 @@ func (r *RDB) Archive(msg *base.TaskMessage, errMsg string) error { cutoff.Unix(), maxArchiveSize, expireAt.Unix(), - base.MaxInt64, + math.MaxInt64, } return r.runScript(ctx, op, archiveCmd, keys, argv...) }