mirror of
https://github.com/oarkflow/mq.git
synced 2025-10-05 16:06:55 +08:00
feat: [wip] - implement storage
This commit is contained in:
22
queue.go
22
queue.go
@@ -21,14 +21,24 @@ func newQueue(name string, queueSize int) *Queue {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Broker) NewQueue(qName string) *Queue {
|
||||
q, ok := b.queues.Get(qName)
|
||||
if ok {
|
||||
return q
|
||||
func (b *Broker) NewQueue(name string) *Queue {
|
||||
q := &Queue{
|
||||
name: name,
|
||||
tasks: make(chan *QueuedTask, b.opts.queueSize),
|
||||
consumers: memory.New[string, *consumer](),
|
||||
}
|
||||
q = newQueue(qName, b.opts.queueSize)
|
||||
b.queues.Set(qName, q)
|
||||
b.queues.Set(name, q)
|
||||
|
||||
// Create DLQ for the queue
|
||||
dlq := &Queue{
|
||||
name: name + "_dlq",
|
||||
tasks: make(chan *QueuedTask, b.opts.queueSize),
|
||||
consumers: memory.New[string, *consumer](),
|
||||
}
|
||||
b.deadLetter.Set(name, dlq)
|
||||
|
||||
go b.dispatchWorker(q)
|
||||
go b.dispatchWorker(dlq)
|
||||
return q
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user