Skip to content

Commit

Permalink
Use math.MaxInt64 instead of custom const
Browse files Browse the repository at this point in the history
  • Loading branch information
hibiken committed Dec 19, 2021
1 parent 82d18e3 commit 1ddb2f7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
6 changes: 0 additions & 6 deletions internal/base/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions internal/rdb/rdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ package rdb
import (
"context"
"fmt"
"math"
"time"

"github.com/go-redis/redis/v8"
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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...)
}
Expand Down Expand Up @@ -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...)
}
Expand Down

0 comments on commit 1ddb2f7

Please sign in to comment.