export priority value
This commit is contained in:
parent
61c1ac19a4
commit
ed3d068e80
|
@ -2,7 +2,7 @@ package queue
|
||||||
|
|
||||||
// Constant
|
// Constant
|
||||||
const (
|
const (
|
||||||
priorityCritical = "critical"
|
PriorityCritical = "critical"
|
||||||
priorityDefault = "default"
|
PriorityDefault = "default"
|
||||||
priorityLow = "low"
|
PriorityLow = "low"
|
||||||
)
|
)
|
||||||
|
|
|
@ -52,9 +52,9 @@ func initServer(redisConn asynq.RedisClientOpt, cfg Config) *asynq.ServeMux {
|
||||||
server := asynq.NewServer(redisConn, asynq.Config{
|
server := asynq.NewServer(redisConn, asynq.Config{
|
||||||
Concurrency: cfg.Concurrency,
|
Concurrency: cfg.Concurrency,
|
||||||
Queues: map[string]int{
|
Queues: map[string]int{
|
||||||
priorityCritical: cfg.Priority.Critical,
|
PriorityCritical: cfg.Priority.Critical,
|
||||||
priorityDefault: cfg.Priority.Default,
|
PriorityDefault: cfg.Priority.Default,
|
||||||
priorityLow: cfg.Priority.Low,
|
PriorityLow: cfg.Priority.Low,
|
||||||
},
|
},
|
||||||
StrictPriority: cfg.Priority.StrictMode,
|
StrictPriority: cfg.Priority.StrictMode,
|
||||||
|
|
||||||
|
|
7
task.go
7
task.go
|
@ -5,11 +5,16 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
// RunTask ...
|
// RunTask ...
|
||||||
func (i Instance) RunTask(typename string, payload []byte, retryTimes int) (*asynq.TaskInfo, error) {
|
func (i Instance) RunTask(typename string, payload []byte, priority string, retryTimes int) (*asynq.TaskInfo, error) {
|
||||||
// Create task and options
|
// Create task and options
|
||||||
task := asynq.NewTask(typename, payload)
|
task := asynq.NewTask(typename, payload)
|
||||||
options := make([]asynq.Option, 0)
|
options := make([]asynq.Option, 0)
|
||||||
|
|
||||||
|
// Priority
|
||||||
|
if priority != PriorityCritical && priority != PriorityDefault && priority != PriorityLow {
|
||||||
|
priority = PriorityDefault
|
||||||
|
}
|
||||||
|
|
||||||
// Retry times
|
// Retry times
|
||||||
if retryTimes < 0 {
|
if retryTimes < 0 {
|
||||||
retryTimes = 0
|
retryTimes = 0
|
||||||
|
|
Loading…
Reference in New Issue