2
0
mirror of https://github.com/hibiken/asynq.git synced 2025-08-19 15:08:55 +08:00

Minor improvement

This commit is contained in:
Ken Hibino
2019-12-09 20:37:30 -08:00
parent 8830d23388
commit ea28d3cac1
4 changed files with 41 additions and 41 deletions

View File

@@ -53,11 +53,11 @@ func enq(cmd *cobra.Command, args []string) {
}))
switch qtype {
case "s":
err = r.EnqueueScheduledTask(id.String(), float64(score))
err = r.EnqueueScheduledTask(id, score)
case "r":
err = r.EnqueueRetryTask(id.String(), float64(score))
err = r.EnqueueRetryTask(id, score)
case "d":
err = r.EnqueueDeadTask(id.String(), float64(score))
err = r.EnqueueDeadTask(id, score)
default:
fmt.Println("invalid argument")
os.Exit(1)

View File

@@ -81,7 +81,7 @@ func queryID(id uuid.UUID, score int64, qtype string) string {
// parseQueryID is a reverse operation of queryID function.
// It takes a queryID and return each part of id with proper
// type if valid, otherwise it reports an error.
func parseQueryID(queryID string) (id uuid.UUID, score float64, qtype string, err error) {
func parseQueryID(queryID string) (id uuid.UUID, score int64, qtype string, err error) {
parts := strings.Split(queryID, ":")
if len(parts) != 3 {
return uuid.Nil, 0, "", fmt.Errorf("invalid id")
@@ -90,7 +90,7 @@ func parseQueryID(queryID string) (id uuid.UUID, score float64, qtype string, er
if err != nil {
return uuid.Nil, 0, "", fmt.Errorf("invalid id")
}
score, err = strconv.ParseFloat(parts[1], 64)
score, err = strconv.ParseInt(parts[1], 10, 64)
if err != nil {
return uuid.Nil, 0, "", fmt.Errorf("invalid id")
}