mirror of
https://github.com/hibiken/asynq.git
synced 2024-11-10 11:31:58 +08:00
Merge pull request #12 from hibiken/feature/shorter_id
Use rs/xid package for more compact string representation of task IDs
This commit is contained in:
commit
193d27d93d
1
asynq.go
1
asynq.go
@ -4,7 +4,6 @@ import "github.com/go-redis/redis/v7"
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
TODOs:
|
TODOs:
|
||||||
- [P0] enqall command to enq all tasks from "scheduled" "retry", "dead" queue
|
|
||||||
- [P0] asynqmon del <taskID>, asynqmon delall <qname>
|
- [P0] asynqmon del <taskID>, asynqmon delall <qname>
|
||||||
- [P0] asynqmon kill <taskID>, asynqmon killall <qname>
|
- [P0] asynqmon kill <taskID>, asynqmon killall <qname>
|
||||||
- [P0] Redis Memory Usage, Connection info in stats
|
- [P0] Redis Memory Usage, Connection info in stats
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
|
|
||||||
"github.com/go-redis/redis/v7"
|
"github.com/go-redis/redis/v7"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/hibiken/asynq/internal/rdb"
|
"github.com/hibiken/asynq/internal/rdb"
|
||||||
|
"github.com/rs/xid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// This file defines test helper functions used by
|
// This file defines test helper functions used by
|
||||||
@ -61,7 +61,7 @@ var sortMsgOpt = cmp.Transformer("SortMsg", func(in []*rdb.TaskMessage) []*rdb.T
|
|||||||
|
|
||||||
func randomTask(taskType, qname string, payload map[string]interface{}) *rdb.TaskMessage {
|
func randomTask(taskType, qname string, payload map[string]interface{}) *rdb.TaskMessage {
|
||||||
return &rdb.TaskMessage{
|
return &rdb.TaskMessage{
|
||||||
ID: uuid.New(),
|
ID: xid.New(),
|
||||||
Type: taskType,
|
Type: taskType,
|
||||||
Queue: qname,
|
Queue: qname,
|
||||||
Retry: defaultMaxRetry,
|
Retry: defaultMaxRetry,
|
||||||
|
@ -3,7 +3,7 @@ package asynq
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/google/uuid"
|
"github.com/rs/xid"
|
||||||
"github.com/hibiken/asynq/internal/rdb"
|
"github.com/hibiken/asynq/internal/rdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -29,7 +29,7 @@ func NewClient(cfg *RedisConfig) *Client {
|
|||||||
// otherwise returns non-nil error.
|
// otherwise returns non-nil error.
|
||||||
func (c *Client) Process(task *Task, processAt time.Time) error {
|
func (c *Client) Process(task *Task, processAt time.Time) error {
|
||||||
msg := &rdb.TaskMessage{
|
msg := &rdb.TaskMessage{
|
||||||
ID: uuid.New(),
|
ID: xid.New(),
|
||||||
Type: task.Type,
|
Type: task.Type,
|
||||||
Payload: task.Payload,
|
Payload: task.Payload,
|
||||||
Queue: "default",
|
Queue: "default",
|
||||||
|
3
go.mod
3
go.mod
@ -3,12 +3,11 @@ module github.com/hibiken/asynq
|
|||||||
go 1.13
|
go 1.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/go-redis/redis v6.15.6+incompatible
|
|
||||||
github.com/go-redis/redis/v7 v7.0.0-beta.4
|
github.com/go-redis/redis/v7 v7.0.0-beta.4
|
||||||
github.com/google/go-cmp v0.3.1
|
github.com/google/go-cmp v0.3.1
|
||||||
github.com/google/uuid v1.1.1
|
|
||||||
github.com/mitchellh/go-homedir v1.1.0
|
github.com/mitchellh/go-homedir v1.1.0
|
||||||
github.com/pelletier/go-toml v1.6.0 // indirect
|
github.com/pelletier/go-toml v1.6.0 // indirect
|
||||||
|
github.com/rs/xid v1.2.1
|
||||||
github.com/spf13/afero v1.2.2 // indirect
|
github.com/spf13/afero v1.2.2 // indirect
|
||||||
github.com/spf13/cobra v0.0.5
|
github.com/spf13/cobra v0.0.5
|
||||||
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
github.com/spf13/jwalterweatherman v1.1.0 // indirect
|
||||||
|
19
go.sum
19
go.sum
@ -1,4 +1,5 @@
|
|||||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||||
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
|
||||||
@ -15,6 +16,7 @@ github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee
|
|||||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||||
@ -24,8 +26,6 @@ github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeME
|
|||||||
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as=
|
||||||
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
|
||||||
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
|
||||||
github.com/go-redis/redis v6.15.6+incompatible h1:H9evprGPLI8+ci7fxQx6WNZHJSb7be8FqJQRhdQZ5Sg=
|
|
||||||
github.com/go-redis/redis v6.15.6+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA=
|
|
||||||
github.com/go-redis/redis/v7 v7.0.0-beta.4 h1:p6z7Pde69EGRWvlC++y8aFcaWegyrKHzOBGo0zUACTQ=
|
github.com/go-redis/redis/v7 v7.0.0-beta.4 h1:p6z7Pde69EGRWvlC++y8aFcaWegyrKHzOBGo0zUACTQ=
|
||||||
github.com/go-redis/redis/v7 v7.0.0-beta.4/go.mod h1:xhhSbUMTsleRPur+Vgx9sUHtyN33bdjxY+9/0n9Ig8s=
|
github.com/go-redis/redis/v7 v7.0.0-beta.4/go.mod h1:xhhSbUMTsleRPur+Vgx9sUHtyN33bdjxY+9/0n9Ig8s=
|
||||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
@ -35,13 +35,13 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
|
|||||||
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=
|
||||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
||||||
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
|
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
|
||||||
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
|
||||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
|
||||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||||
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
|
||||||
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
|
||||||
@ -54,14 +54,17 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
|
|||||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||||
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
|
||||||
|
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
|
||||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||||
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
|
||||||
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
|
||||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
|
||||||
|
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
|
||||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY=
|
||||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||||
@ -84,6 +87,7 @@ github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/9
|
|||||||
github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4=
|
github.com/pelletier/go-toml v1.6.0 h1:aetoXYr0Tv7xRU/V4B4IZJ2QcbtMUFoNb3ORp7TzIK4=
|
||||||
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=
|
github.com/pelletier/go-toml v1.6.0/go.mod h1:5N711Q9dKgbdkxHL+MEfF31hpT7l0S0s/t2kKREewys=
|
||||||
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
||||||
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
|
||||||
@ -95,9 +99,13 @@ github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R
|
|||||||
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
|
||||||
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU=
|
||||||
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg=
|
||||||
|
github.com/rs/xid v1.2.1 h1:mhH9Nq+C1fY2l1XIpgxIiUOfNpRBYH1kKcr+qfKgjRc=
|
||||||
|
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||||
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
|
||||||
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
|
||||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||||
|
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
|
||||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||||
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
|
||||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||||
@ -122,6 +130,7 @@ github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DM
|
|||||||
github.com/spf13/viper v1.6.0 h1:qSjVKzM2dmqQLutPN4Y0SEzDpAf7T6HHIT3E2Xr75Gg=
|
github.com/spf13/viper v1.6.0 h1:qSjVKzM2dmqQLutPN4Y0SEzDpAf7T6HHIT3E2Xr75Gg=
|
||||||
github.com/spf13/viper v1.6.0/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
|
github.com/spf13/viper v1.6.0/go.mod h1:t3iDnF5Jlj76alVNuyFBk5oUMCvsrkbvZK0WQdfDi5k=
|
||||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
|
||||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
|
||||||
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
|
||||||
@ -147,6 +156,7 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73r
|
|||||||
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||||
|
golang.org/x/net v0.0.0-20190522155817-f3200d17e092 h1:4QSRKanuywn15aTZvI/mIDEgPQpswuFndXpOj3rKEco=
|
||||||
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
golang.org/x/net v0.0.0-20190522155817-f3200d17e092/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@ -179,6 +189,7 @@ google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZi
|
|||||||
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
google.golang.org/grpc v1.21.0/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM=
|
||||||
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
|
||||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
|
||||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v7"
|
"github.com/go-redis/redis/v7"
|
||||||
"github.com/google/uuid"
|
"github.com/rs/xid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Stats represents a state of queues at a certain time.
|
// Stats represents a state of queues at a certain time.
|
||||||
@ -22,7 +22,7 @@ type Stats struct {
|
|||||||
// EnqueuedTask is a task in a queue and is ready to be processed.
|
// EnqueuedTask is a task in a queue and is ready to be processed.
|
||||||
// Note: This is read only and used for monitoring purpose.
|
// Note: This is read only and used for monitoring purpose.
|
||||||
type EnqueuedTask struct {
|
type EnqueuedTask struct {
|
||||||
ID uuid.UUID
|
ID xid.ID
|
||||||
Type string
|
Type string
|
||||||
Payload map[string]interface{}
|
Payload map[string]interface{}
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ type EnqueuedTask struct {
|
|||||||
// InProgressTask is a task that's currently being processed.
|
// InProgressTask is a task that's currently being processed.
|
||||||
// Note: This is read only and used for monitoring purpose.
|
// Note: This is read only and used for monitoring purpose.
|
||||||
type InProgressTask struct {
|
type InProgressTask struct {
|
||||||
ID uuid.UUID
|
ID xid.ID
|
||||||
Type string
|
Type string
|
||||||
Payload map[string]interface{}
|
Payload map[string]interface{}
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ type InProgressTask struct {
|
|||||||
// ScheduledTask is a task that's scheduled to be processed in the future.
|
// ScheduledTask is a task that's scheduled to be processed in the future.
|
||||||
// Note: This is read only and used for monitoring purpose.
|
// Note: This is read only and used for monitoring purpose.
|
||||||
type ScheduledTask struct {
|
type ScheduledTask struct {
|
||||||
ID uuid.UUID
|
ID xid.ID
|
||||||
Type string
|
Type string
|
||||||
Payload map[string]interface{}
|
Payload map[string]interface{}
|
||||||
ProcessAt time.Time
|
ProcessAt time.Time
|
||||||
@ -48,7 +48,7 @@ type ScheduledTask struct {
|
|||||||
// RetryTask is a task that's in retry queue because worker failed to process the task.
|
// RetryTask is a task that's in retry queue because worker failed to process the task.
|
||||||
// Note: This is read only and used for monitoring purpose.
|
// Note: This is read only and used for monitoring purpose.
|
||||||
type RetryTask struct {
|
type RetryTask struct {
|
||||||
ID uuid.UUID
|
ID xid.ID
|
||||||
Type string
|
Type string
|
||||||
Payload map[string]interface{}
|
Payload map[string]interface{}
|
||||||
// TODO(hibiken): add LastFailedAt time.Time
|
// TODO(hibiken): add LastFailedAt time.Time
|
||||||
@ -62,7 +62,7 @@ type RetryTask struct {
|
|||||||
// DeadTask is a task in that has exhausted all retries.
|
// DeadTask is a task in that has exhausted all retries.
|
||||||
// Note: This is read only and used for monitoring purpose.
|
// Note: This is read only and used for monitoring purpose.
|
||||||
type DeadTask struct {
|
type DeadTask struct {
|
||||||
ID uuid.UUID
|
ID xid.ID
|
||||||
Type string
|
Type string
|
||||||
Payload map[string]interface{}
|
Payload map[string]interface{}
|
||||||
LastFailedAt time.Time
|
LastFailedAt time.Time
|
||||||
@ -233,7 +233,7 @@ func (r *RDB) ListDead() ([]*DeadTask, error) {
|
|||||||
// EnqueueDeadTask finds a task that matches the given id and score from dead queue
|
// EnqueueDeadTask finds a task that matches the given id and score from dead queue
|
||||||
// and enqueues it for processing. If a task that matches the id and score
|
// and enqueues it for processing. If a task that matches the id and score
|
||||||
// does not exist, it returns ErrTaskNotFound.
|
// does not exist, it returns ErrTaskNotFound.
|
||||||
func (r *RDB) EnqueueDeadTask(id uuid.UUID, score int64) error {
|
func (r *RDB) EnqueueDeadTask(id xid.ID, score int64) error {
|
||||||
n, err := r.removeAndEnqueue(deadQ, id.String(), float64(score))
|
n, err := r.removeAndEnqueue(deadQ, id.String(), float64(score))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -247,7 +247,7 @@ func (r *RDB) EnqueueDeadTask(id uuid.UUID, score int64) error {
|
|||||||
// EnqueueRetryTask finds a task that matches the given id and score from retry queue
|
// EnqueueRetryTask finds a task that matches the given id and score from retry queue
|
||||||
// and enqueues it for processing. If a task that matches the id and score
|
// and enqueues it for processing. If a task that matches the id and score
|
||||||
// does not exist, it returns ErrTaskNotFound.
|
// does not exist, it returns ErrTaskNotFound.
|
||||||
func (r *RDB) EnqueueRetryTask(id uuid.UUID, score int64) error {
|
func (r *RDB) EnqueueRetryTask(id xid.ID, score int64) error {
|
||||||
n, err := r.removeAndEnqueue(retryQ, id.String(), float64(score))
|
n, err := r.removeAndEnqueue(retryQ, id.String(), float64(score))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -261,7 +261,7 @@ func (r *RDB) EnqueueRetryTask(id uuid.UUID, score int64) error {
|
|||||||
// EnqueueScheduledTask finds a task that matches the given id and score from scheduled queue
|
// EnqueueScheduledTask finds a task that matches the given id and score from scheduled queue
|
||||||
// and enqueues it for processing. If a task that matches the id and score does not
|
// and enqueues it for processing. If a task that matches the id and score does not
|
||||||
// exist, it returns ErrTaskNotFound.
|
// exist, it returns ErrTaskNotFound.
|
||||||
func (r *RDB) EnqueueScheduledTask(id uuid.UUID, score int64) error {
|
func (r *RDB) EnqueueScheduledTask(id xid.ID, score int64) error {
|
||||||
n, err := r.removeAndEnqueue(scheduledQ, id.String(), float64(score))
|
n, err := r.removeAndEnqueue(scheduledQ, id.String(), float64(score))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-redis/redis/v7"
|
"github.com/go-redis/redis/v7"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/uuid"
|
"github.com/rs/xid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO(hibiken): Replace this with cmpopts.EquateApproxTime once it becomes availalble.
|
// TODO(hibiken): Replace this with cmpopts.EquateApproxTime once it becomes availalble.
|
||||||
@ -310,7 +310,7 @@ func TestListScheduled(t *testing.T) {
|
|||||||
func TestListRetry(t *testing.T) {
|
func TestListRetry(t *testing.T) {
|
||||||
r := setup(t)
|
r := setup(t)
|
||||||
m1 := &TaskMessage{
|
m1 := &TaskMessage{
|
||||||
ID: uuid.New(),
|
ID: xid.New(),
|
||||||
Type: "send_email",
|
Type: "send_email",
|
||||||
Queue: "default",
|
Queue: "default",
|
||||||
Payload: map[string]interface{}{"subject": "hello"},
|
Payload: map[string]interface{}{"subject": "hello"},
|
||||||
@ -319,7 +319,7 @@ func TestListRetry(t *testing.T) {
|
|||||||
Retried: 10,
|
Retried: 10,
|
||||||
}
|
}
|
||||||
m2 := &TaskMessage{
|
m2 := &TaskMessage{
|
||||||
ID: uuid.New(),
|
ID: xid.New(),
|
||||||
Type: "reindex",
|
Type: "reindex",
|
||||||
Queue: "default",
|
Queue: "default",
|
||||||
Payload: nil,
|
Payload: nil,
|
||||||
@ -394,14 +394,14 @@ func TestListRetry(t *testing.T) {
|
|||||||
func TestListDead(t *testing.T) {
|
func TestListDead(t *testing.T) {
|
||||||
r := setup(t)
|
r := setup(t)
|
||||||
m1 := &TaskMessage{
|
m1 := &TaskMessage{
|
||||||
ID: uuid.New(),
|
ID: xid.New(),
|
||||||
Type: "send_email",
|
Type: "send_email",
|
||||||
Queue: "default",
|
Queue: "default",
|
||||||
Payload: map[string]interface{}{"subject": "hello"},
|
Payload: map[string]interface{}{"subject": "hello"},
|
||||||
ErrorMsg: "email server not responding",
|
ErrorMsg: "email server not responding",
|
||||||
}
|
}
|
||||||
m2 := &TaskMessage{
|
m2 := &TaskMessage{
|
||||||
ID: uuid.New(),
|
ID: xid.New(),
|
||||||
Type: "reindex",
|
Type: "reindex",
|
||||||
Queue: "default",
|
Queue: "default",
|
||||||
Payload: nil,
|
Payload: nil,
|
||||||
@ -485,7 +485,7 @@ func TestEnqueueDeadTask(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
dead []deadEntry
|
dead []deadEntry
|
||||||
score int64
|
score int64
|
||||||
id uuid.UUID
|
id xid.ID
|
||||||
want error // expected return value from calling EnqueueDeadTask
|
want error // expected return value from calling EnqueueDeadTask
|
||||||
wantDead []*TaskMessage
|
wantDead []*TaskMessage
|
||||||
wantEnqueued []*TaskMessage
|
wantEnqueued []*TaskMessage
|
||||||
@ -561,7 +561,7 @@ func TestEnqueueRetryTask(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
dead []retryEntry
|
dead []retryEntry
|
||||||
score int64
|
score int64
|
||||||
id uuid.UUID
|
id xid.ID
|
||||||
want error // expected return value from calling EnqueueRetryTask
|
want error // expected return value from calling EnqueueRetryTask
|
||||||
wantRetry []*TaskMessage
|
wantRetry []*TaskMessage
|
||||||
wantEnqueued []*TaskMessage
|
wantEnqueued []*TaskMessage
|
||||||
@ -637,7 +637,7 @@ func TestEnqueueScheduledTask(t *testing.T) {
|
|||||||
tests := []struct {
|
tests := []struct {
|
||||||
dead []scheduledEntry
|
dead []scheduledEntry
|
||||||
score int64
|
score int64
|
||||||
id uuid.UUID
|
id xid.ID
|
||||||
want error // expected return value from calling EnqueueScheduledTask
|
want error // expected return value from calling EnqueueScheduledTask
|
||||||
wantScheduled []*TaskMessage
|
wantScheduled []*TaskMessage
|
||||||
wantEnqueued []*TaskMessage
|
wantEnqueued []*TaskMessage
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v7"
|
"github.com/go-redis/redis/v7"
|
||||||
"github.com/google/uuid"
|
"github.com/rs/xid"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Redis keys
|
// Redis keys
|
||||||
@ -51,7 +51,7 @@ type TaskMessage struct {
|
|||||||
|
|
||||||
//-------- Metadata fields --------
|
//-------- Metadata fields --------
|
||||||
// ID is a unique identifier for each task
|
// ID is a unique identifier for each task
|
||||||
ID uuid.UUID
|
ID xid.ID
|
||||||
// Queue is a name this message should be enqueued to
|
// Queue is a name this message should be enqueued to
|
||||||
Queue string
|
Queue string
|
||||||
// Retry is the max number of retry for this task.
|
// Retry is the max number of retry for this task.
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
"github.com/go-redis/redis/v7"
|
"github.com/go-redis/redis/v7"
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/uuid"
|
"github.com/rs/xid"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
@ -40,7 +40,7 @@ var sortMsgOpt = cmp.Transformer("SortMsg", func(in []*TaskMessage) []*TaskMessa
|
|||||||
|
|
||||||
func randomTask(taskType, qname string, payload map[string]interface{}) *TaskMessage {
|
func randomTask(taskType, qname string, payload map[string]interface{}) *TaskMessage {
|
||||||
return &TaskMessage{
|
return &TaskMessage{
|
||||||
ID: uuid.New(),
|
ID: xid.New(),
|
||||||
Type: taskType,
|
Type: taskType,
|
||||||
Queue: qname,
|
Queue: qname,
|
||||||
Retry: 25,
|
Retry: 25,
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/google/go-cmp/cmp"
|
"github.com/google/go-cmp/cmp"
|
||||||
"github.com/google/uuid"
|
"github.com/rs/xid"
|
||||||
"github.com/hibiken/asynq/internal/rdb"
|
"github.com/hibiken/asynq/internal/rdb"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -14,12 +14,12 @@ func TestRetry(t *testing.T) {
|
|||||||
rdbClient := rdb.NewRDB(r)
|
rdbClient := rdb.NewRDB(r)
|
||||||
errMsg := "email server not responding"
|
errMsg := "email server not responding"
|
||||||
// t1 is a task with max-retry count reached.
|
// t1 is a task with max-retry count reached.
|
||||||
t1 := &rdb.TaskMessage{Type: "send_email", Retry: 10, Retried: 10, Queue: "default", ID: uuid.New()}
|
t1 := &rdb.TaskMessage{Type: "send_email", Retry: 10, Retried: 10, Queue: "default", ID: xid.New()}
|
||||||
// t2 is t1 with updated error message.
|
// t2 is t1 with updated error message.
|
||||||
t2 := *t1
|
t2 := *t1
|
||||||
t2.ErrorMsg = errMsg
|
t2.ErrorMsg = errMsg
|
||||||
// t3 is a task which hasn't reached max-retry count.
|
// t3 is a task which hasn't reached max-retry count.
|
||||||
t3 := &rdb.TaskMessage{Type: "send_email", Retry: 10, Retried: 5, Queue: "default", ID: uuid.New()}
|
t3 := &rdb.TaskMessage{Type: "send_email", Retry: 10, Retried: 5, Queue: "default", ID: xid.New()}
|
||||||
// t4 is t3 after retry.
|
// t4 is t3 after retry.
|
||||||
t4 := *t3
|
t4 := *t3
|
||||||
t4.Retried++
|
t4.Retried++
|
||||||
|
@ -22,7 +22,7 @@ Identifier for a task should be obtained by running "asynqmon ls" command.
|
|||||||
The task enqueued by this command will be processed as soon as the task
|
The task enqueued by this command will be processed as soon as the task
|
||||||
gets dequeued by a processor.
|
gets dequeued by a processor.
|
||||||
|
|
||||||
Example: asynqmon enq d:1575732274:b0415aa2-fd33-4b63-87c4-2f1a954ea4bf`,
|
Example: asynqmon enq d:1575732274:bnogo8gt6toe23vhef0g`,
|
||||||
Args: cobra.ExactArgs(1),
|
Args: cobra.ExactArgs(1),
|
||||||
Run: enq,
|
Run: enq,
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-redis/redis/v7"
|
"github.com/go-redis/redis/v7"
|
||||||
"github.com/google/uuid"
|
|
||||||
"github.com/hibiken/asynq/internal/rdb"
|
"github.com/hibiken/asynq/internal/rdb"
|
||||||
|
"github.com/rs/xid"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ func ls(cmd *cobra.Command, args []string) {
|
|||||||
// queryID returns an identifier used for "enq" command.
|
// queryID returns an identifier used for "enq" command.
|
||||||
// score is the zset score and queryType should be one
|
// score is the zset score and queryType should be one
|
||||||
// of "s", "r" or "d" (scheduled, retry, dead respectively).
|
// of "s", "r" or "d" (scheduled, retry, dead respectively).
|
||||||
func queryID(id uuid.UUID, score int64, qtype string) string {
|
func queryID(id xid.ID, score int64, qtype string) string {
|
||||||
const format = "%v:%v:%v"
|
const format = "%v:%v:%v"
|
||||||
return fmt.Sprintf(format, qtype, score, id)
|
return fmt.Sprintf(format, qtype, score, id)
|
||||||
}
|
}
|
||||||
@ -81,22 +81,22 @@ func queryID(id uuid.UUID, score int64, qtype string) string {
|
|||||||
// parseQueryID is a reverse operation of queryID function.
|
// parseQueryID is a reverse operation of queryID function.
|
||||||
// It takes a queryID and return each part of id with proper
|
// It takes a queryID and return each part of id with proper
|
||||||
// type if valid, otherwise it reports an error.
|
// type if valid, otherwise it reports an error.
|
||||||
func parseQueryID(queryID string) (id uuid.UUID, score int64, qtype string, err error) {
|
func parseQueryID(queryID string) (id xid.ID, score int64, qtype string, err error) {
|
||||||
parts := strings.Split(queryID, ":")
|
parts := strings.Split(queryID, ":")
|
||||||
if len(parts) != 3 {
|
if len(parts) != 3 {
|
||||||
return uuid.Nil, 0, "", fmt.Errorf("invalid id")
|
return xid.NilID(), 0, "", fmt.Errorf("invalid id")
|
||||||
}
|
}
|
||||||
id, err = uuid.Parse(parts[2])
|
id, err = xid.FromString(parts[2])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return uuid.Nil, 0, "", fmt.Errorf("invalid id")
|
return xid.NilID(), 0, "", fmt.Errorf("invalid id")
|
||||||
}
|
}
|
||||||
score, err = strconv.ParseInt(parts[1], 10, 64)
|
score, err = strconv.ParseInt(parts[1], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return uuid.Nil, 0, "", fmt.Errorf("invalid id")
|
return xid.NilID(), 0, "", fmt.Errorf("invalid id")
|
||||||
}
|
}
|
||||||
qtype = parts[0]
|
qtype = parts[0]
|
||||||
if len(qtype) != 1 || !strings.Contains("srd", qtype) {
|
if len(qtype) != 1 || !strings.Contains("srd", qtype) {
|
||||||
return uuid.Nil, 0, "", fmt.Errorf("invalid id")
|
return xid.NilID(), 0, "", fmt.Errorf("invalid id")
|
||||||
}
|
}
|
||||||
return id, score, qtype, nil
|
return id, score, qtype, nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user