未验证 提交 2d513f35 编写于 作者: N NAND86 提交者: GitHub

fix crash on selecting queue. (#643)

上级 cccc4546
......@@ -44,6 +44,7 @@ func (manualQueueSelector) Select(message *primitive.Message, queues []*primitiv
// randomQueueSelector choose a random queue each time.
type randomQueueSelector struct {
mux sync.Mutex
rander *rand.Rand
}
......@@ -53,8 +54,10 @@ func NewRandomQueueSelector() QueueSelector {
return s
}
func (r randomQueueSelector) Select(message *primitive.Message, queues []*primitive.MessageQueue) *primitive.MessageQueue {
func (r *randomQueueSelector) Select(message *primitive.Message, queues []*primitive.MessageQueue) *primitive.MessageQueue {
r.mux.Lock()
i := r.rander.Intn(len(queues))
r.mux.Unlock()
return queues[i]
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册