mirror of
https://github.com/hibiken/asynq.git
synced 2025-10-25 23:06:12 +08:00
Change UTC timezone to system time
This commit is contained in:
@@ -168,12 +168,12 @@ func FailedTotalKey(qname string) string {
|
||||
|
||||
// ProcessedKey returns a redis key for processed count for the given day for the queue.
|
||||
func ProcessedKey(qname string, t time.Time) string {
|
||||
return fmt.Sprintf("%sprocessed:%s", QueueKeyPrefix(qname), t.UTC().Format("2006-01-02"))
|
||||
return fmt.Sprintf("%sprocessed:%s", QueueKeyPrefix(qname), t.In(time.Local).Format("2006-01-02"))
|
||||
}
|
||||
|
||||
// FailedKey returns a redis key for failure count for the given day for the queue.
|
||||
func FailedKey(qname string, t time.Time) string {
|
||||
return fmt.Sprintf("%sfailed:%s", QueueKeyPrefix(qname), t.UTC().Format("2006-01-02"))
|
||||
return fmt.Sprintf("%sfailed:%s", QueueKeyPrefix(qname), t.In(time.Local).Format("2006-01-02"))
|
||||
}
|
||||
|
||||
// ServerInfoKey returns a redis key for process info.
|
||||
|
||||
@@ -214,9 +214,9 @@ func TestProcessedKey(t *testing.T) {
|
||||
input time.Time
|
||||
want string
|
||||
}{
|
||||
{"default", time.Date(2019, 11, 14, 10, 30, 1, 1, time.UTC), "asynq:{default}:processed:2019-11-14"},
|
||||
{"critical", time.Date(2020, 12, 1, 1, 0, 1, 1, time.UTC), "asynq:{critical}:processed:2020-12-01"},
|
||||
{"default", time.Date(2020, 1, 6, 15, 02, 1, 1, time.UTC), "asynq:{default}:processed:2020-01-06"},
|
||||
{"default", time.Date(2019, 11, 14, 10, 30, 1, 1, time.Local), "asynq:{default}:processed:2019-11-14"},
|
||||
{"critical", time.Date(2020, 12, 1, 1, 0, 1, 1, time.Local), "asynq:{critical}:processed:2020-12-01"},
|
||||
{"default", time.Date(2020, 1, 6, 15, 02, 1, 1, time.Local), "asynq:{default}:processed:2020-01-06"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
@@ -233,9 +233,9 @@ func TestFailedKey(t *testing.T) {
|
||||
input time.Time
|
||||
want string
|
||||
}{
|
||||
{"default", time.Date(2019, 11, 14, 10, 30, 1, 1, time.UTC), "asynq:{default}:failed:2019-11-14"},
|
||||
{"custom", time.Date(2020, 12, 1, 1, 0, 1, 1, time.UTC), "asynq:{custom}:failed:2020-12-01"},
|
||||
{"low", time.Date(2020, 1, 6, 15, 02, 1, 1, time.UTC), "asynq:{low}:failed:2020-01-06"},
|
||||
{"default", time.Date(2019, 11, 14, 10, 30, 1, 1, time.Local), "asynq:{default}:failed:2019-11-14"},
|
||||
{"custom", time.Date(2020, 12, 1, 1, 0, 1, 1, time.Local), "asynq:{custom}:failed:2020-12-01"},
|
||||
{"low", time.Date(2020, 1, 6, 15, 02, 1, 1, time.Local), "asynq:{low}:failed:2020-01-06"},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
@@ -336,7 +336,7 @@ func TestUniqueKey(t *testing.T) {
|
||||
"address": map[string]string{"line": "123 Main St", "city": "Boston", "state": "MA"},
|
||||
"names": []string{"bob", "mike", "rob"}})
|
||||
payload4 := toBytes(map[string]interface{}{
|
||||
"time": time.Date(2020, time.July, 28, 0, 0, 0, 0, time.UTC),
|
||||
"time": time.Date(2020, time.July, 28, 0, 0, 0, 0, time.Local),
|
||||
"duration": time.Hour})
|
||||
|
||||
checksum := func(data []byte) string {
|
||||
@@ -633,8 +633,8 @@ func TestSchedulerEntryEncoding(t *testing.T) {
|
||||
Type: "task_A",
|
||||
Payload: toBytes(map[string]interface{}{"foo": "bar"}),
|
||||
Opts: []string{"Queue('email')"},
|
||||
Next: time.Now().Add(30 * time.Second).UTC(),
|
||||
Prev: time.Now().Add(-2 * time.Minute).UTC(),
|
||||
Next: time.Now().Add(30 * time.Second),
|
||||
Prev: time.Now().Add(-2 * time.Minute),
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -664,7 +664,7 @@ func TestSchedulerEnqueueEventEncoding(t *testing.T) {
|
||||
{
|
||||
event: SchedulerEnqueueEvent{
|
||||
TaskID: uuid.NewString(),
|
||||
EnqueuedAt: time.Now().Add(-30 * time.Second).UTC(),
|
||||
EnqueuedAt: time.Now().Add(-30 * time.Second),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func (l *baseLogger) prefixPrint(prefix string, args ...interface{}) {
|
||||
func newBase(out io.Writer) *baseLogger {
|
||||
prefix := fmt.Sprintf("asynq: pid=%d ", os.Getpid())
|
||||
return &baseLogger{
|
||||
stdlog.New(out, prefix, stdlog.Ldate|stdlog.Ltime|stdlog.Lmicroseconds|stdlog.LUTC),
|
||||
stdlog.New(out, prefix, stdlog.Ldate|stdlog.Ltime|stdlog.Lmicroseconds),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -373,7 +373,7 @@ func (r *RDB) HistoricalStats(qname string, n int) ([]*DailyStats, error) {
|
||||
return nil, errors.E(op, errors.NotFound, &errors.QueueNotFoundError{Queue: qname})
|
||||
}
|
||||
const day = 24 * time.Hour
|
||||
now := r.clock.Now().UTC()
|
||||
now := r.clock.Now()
|
||||
var days []time.Time
|
||||
var keys []string
|
||||
for i := 0; i < n; i++ {
|
||||
|
||||
@@ -343,7 +343,7 @@ func TestCurrentStatsWithNonExistentQueue(t *testing.T) {
|
||||
func TestHistoricalStats(t *testing.T) {
|
||||
r := setup(t)
|
||||
defer r.Close()
|
||||
now := time.Now().UTC()
|
||||
now := time.Now()
|
||||
|
||||
tests := []struct {
|
||||
qname string // queue of interest
|
||||
@@ -5326,7 +5326,7 @@ func TestListWorkers(t *testing.T) {
|
||||
|
||||
func TestWriteListClearSchedulerEntries(t *testing.T) {
|
||||
r := setup(t)
|
||||
now := time.Now().UTC()
|
||||
now := time.Now()
|
||||
schedulerID := "127.0.0.1:9876:abc123"
|
||||
|
||||
data := []*base.SchedulerEntry{
|
||||
|
||||
@@ -1356,7 +1356,7 @@ func (r *RDB) WriteServerState(info *base.ServerInfo, workers []*base.WorkerInfo
|
||||
if err != nil {
|
||||
return errors.E(op, errors.Internal, fmt.Sprintf("cannot encode server info: %v", err))
|
||||
}
|
||||
exp := r.clock.Now().Add(ttl).UTC()
|
||||
exp := r.clock.Now().Add(ttl)
|
||||
args := []interface{}{ttl.Seconds(), bytes} // args to the lua script
|
||||
for _, w := range workers {
|
||||
bytes, err := base.EncodeWorkerInfo(w)
|
||||
@@ -1421,7 +1421,7 @@ func (r *RDB) WriteSchedulerEntries(schedulerID string, entries []*base.Schedule
|
||||
}
|
||||
args = append(args, bytes)
|
||||
}
|
||||
exp := r.clock.Now().Add(ttl).UTC()
|
||||
exp := r.clock.Now().Add(ttl)
|
||||
key := base.SchedulerEntriesKey(schedulerID)
|
||||
err := r.client.ZAdd(ctx, base.AllSchedulers, redis.Z{Score: float64(exp.Unix()), Member: key}).Err()
|
||||
if err != nil {
|
||||
|
||||
@@ -2767,7 +2767,7 @@ func TestWriteServerState(t *testing.T) {
|
||||
Concurrency: 10,
|
||||
Queues: map[string]int{"default": 2, "email": 5, "low": 1},
|
||||
StrictPriority: false,
|
||||
Started: time.Now().UTC(),
|
||||
Started: time.Now(),
|
||||
Status: "active",
|
||||
ActiveWorkerCount: 0,
|
||||
}
|
||||
@@ -2857,7 +2857,7 @@ func TestWriteServerStateWithWorkers(t *testing.T) {
|
||||
Concurrency: 10,
|
||||
Queues: map[string]int{"default": 2, "email": 5, "low": 1},
|
||||
StrictPriority: false,
|
||||
Started: time.Now().Add(-10 * time.Minute).UTC(),
|
||||
Started: time.Now().Add(-10 * time.Minute),
|
||||
Status: "active",
|
||||
ActiveWorkerCount: len(workers),
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ func TestTaskMessageBuilder(t *testing.T) {
|
||||
ops: func(b *TaskMessageBuilder) {
|
||||
b.SetRetry(1).
|
||||
SetTimeout(20 * time.Second).
|
||||
SetDeadline(time.Date(2017, 3, 6, 0, 0, 0, 0, time.UTC))
|
||||
SetDeadline(time.Date(2017, 3, 6, 0, 0, 0, 0, time.Local))
|
||||
},
|
||||
want: &base.TaskMessage{
|
||||
Type: "default_task",
|
||||
@@ -58,7 +58,7 @@ func TestTaskMessageBuilder(t *testing.T) {
|
||||
Payload: nil,
|
||||
Retry: 1,
|
||||
Timeout: 20,
|
||||
Deadline: time.Date(2017, 3, 6, 0, 0, 0, 0, time.UTC).Unix(),
|
||||
Deadline: time.Date(2017, 3, 6, 0, 0, 0, 0, time.Local).Unix(),
|
||||
},
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user