Skip to content

Commit

Permalink
fix: add cron name to sets
Browse files Browse the repository at this point in the history
  • Loading branch information
KagChi committed May 18, 2023
1 parent fafb884 commit 7857724
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion broker/cron_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func CronJob(client redis.UniversalClient, broker Broker, message Message) ([]by
}
}

client.SAdd(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_CRON_SETS, *message.D.Name), taskId).Err()
client.SAdd(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_CRON_SETS, *message.D.Name), fmt.Sprintf("%s:%s", taskId, *message.D.Name)).Err()

log.Infof("Added task with ID %s to run every %v.\n", taskId, timeVal)

Expand Down
4 changes: 2 additions & 2 deletions processor/cron_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func ProcessCronJob(client redis.UniversalClient, broker amqp091.Channel, name s
c.Stop()
client.Unlink(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_KEY_ROUTE, taskId))
client.Unlink(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_CRON_VALUE, name))
client.SRem(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_CRON_SETS, name)).Err()
client.SRem(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_CRON_SETS, fmt.Sprintf("%s:%s", taskId, name))).Err()
return
}

Expand All @@ -50,6 +50,6 @@ func ProcessCronJob(client redis.UniversalClient, broker amqp091.Channel, name s
} else {
client.Unlink(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_KEY_ROUTE, taskId))
client.Unlink(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_CRON_VALUE, name))
client.SRem(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_CRON_SETS, name)).Err()
client.SRem(context.Background(), fmt.Sprintf("%s:%s", constants.TASK_REDIS_CRON_SETS, fmt.Sprintf("%s:%s", taskId, name))).Err()
}
}

0 comments on commit 7857724

Please sign in to comment.