mirror of
https://github.com/hibiken/asynq.git
synced 2024-11-10 11:31:58 +08:00
Use math.MaxInt64 instead of custom const
This commit is contained in:
parent
82d18e3d91
commit
1ddb2f7bce
@ -39,12 +39,6 @@ const (
|
|||||||
CancelChannel = "asynq:cancel" // PubSub channel
|
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.
|
// TaskState denotes the state of a task.
|
||||||
type TaskState int
|
type TaskState int
|
||||||
|
|
||||||
|
@ -8,6 +8,7 @@ package rdb
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v8"
|
"github.com/go-redis/redis/v8"
|
||||||
@ -382,7 +383,7 @@ func (r *RDB) Done(msg *base.TaskMessage) error {
|
|||||||
argv := []interface{}{
|
argv := []interface{}{
|
||||||
msg.ID,
|
msg.ID,
|
||||||
expireAt.Unix(),
|
expireAt.Unix(),
|
||||||
base.MaxInt64,
|
math.MaxInt64,
|
||||||
}
|
}
|
||||||
// Note: We cannot pass empty unique key when running this script in redis-cluster.
|
// Note: We cannot pass empty unique key when running this script in redis-cluster.
|
||||||
if len(msg.UniqueKey) > 0 {
|
if len(msg.UniqueKey) > 0 {
|
||||||
@ -493,7 +494,7 @@ func (r *RDB) MarkAsComplete(msg *base.TaskMessage) error {
|
|||||||
statsExpireAt.Unix(),
|
statsExpireAt.Unix(),
|
||||||
now.Unix() + msg.Retention,
|
now.Unix() + msg.Retention,
|
||||||
encoded,
|
encoded,
|
||||||
base.MaxInt64,
|
math.MaxInt64,
|
||||||
}
|
}
|
||||||
// Note: We cannot pass empty unique key when running this script in redis-cluster.
|
// Note: We cannot pass empty unique key when running this script in redis-cluster.
|
||||||
if len(msg.UniqueKey) > 0 {
|
if len(msg.UniqueKey) > 0 {
|
||||||
@ -735,7 +736,7 @@ func (r *RDB) Retry(msg *base.TaskMessage, processAt time.Time, errMsg string, i
|
|||||||
processAt.Unix(),
|
processAt.Unix(),
|
||||||
expireAt.Unix(),
|
expireAt.Unix(),
|
||||||
isFailure,
|
isFailure,
|
||||||
base.MaxInt64,
|
math.MaxInt64,
|
||||||
}
|
}
|
||||||
return r.runScript(ctx, op, retryCmd, keys, argv...)
|
return r.runScript(ctx, op, retryCmd, keys, argv...)
|
||||||
}
|
}
|
||||||
@ -822,7 +823,7 @@ func (r *RDB) Archive(msg *base.TaskMessage, errMsg string) error {
|
|||||||
cutoff.Unix(),
|
cutoff.Unix(),
|
||||||
maxArchiveSize,
|
maxArchiveSize,
|
||||||
expireAt.Unix(),
|
expireAt.Unix(),
|
||||||
base.MaxInt64,
|
math.MaxInt64,
|
||||||
}
|
}
|
||||||
return r.runScript(ctx, op, archiveCmd, keys, argv...)
|
return r.runScript(ctx, op, archiveCmd, keys, argv...)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user