You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When I choose to use the multi queue with priority, I was curious about the implementation mechanism. So I dig the code in, and seek it in the queues method of the processor, which is https://github.com/hibiken/asynq/blob/master/processor.go#L399
// queues returns a list of queues to query.// Order of the queue names is based on the priority of each queue.// Queue names is sorted by their priority level if strict-priority is true.// If strict-priority is false, then the order of queue names are roughly based on// the priority level but randomized in order to avoid starving low priority queues.func (p*processor) queues() []string {
// skip the overhead of generating a list of queue names// if we are processing one queue.iflen(p.queueConfig) ==1 {
forqname:=rangep.queueConfig {
return []string{qname}
}
}
ifp.orderedQueues!=nil {
returnp.orderedQueues
}
varnames []stringforqname, priority:=rangep.queueConfig {
fori:=0; i<priority; i++ {
names=append(names, qname)
}
}
rand.Shuffle(len(names), func(i, jint) { names[i], names[j] =names[j], names[i] })
returnuniq(names, len(p.queueConfig))
}
I wondering priority variable only affects the composition of the names list and does not affect the final returned queue list. The final queue list is unduplicated and the queues in the configuration are selected with equal probability, rather than increasing the probability of some queues being selected by priority.
Suggestion
Modify uniq function to conclude priority infactors, I will happy to create a pull request if need.
The text was updated successfully, but these errors were encountered:
Describe the bug
When I choose to use the multi queue with priority, I was curious about the implementation mechanism. So I dig the code in, and seek it in the
queues
method of theprocessor
, which is https://github.com/hibiken/asynq/blob/master/processor.go#L399I wondering
priority
variable only affects the composition of the names list and does not affect the final returned queue list. The final queue list is unduplicated and the queues in the configuration are selected with equal probability, rather than increasing the probability of some queues being selected by priority.Suggestion
Modify
uniq
function to conclude priority infactors, I will happy to create a pull request if need.The text was updated successfully, but these errors were encountered: