Skip to content
Prev Previous commit
Next Next commit
Update modules/queue/unique_queue_channel.go
  • Loading branch information
zeripath authored Oct 16, 2021
commit 0518c4bc66b9e801aa6101852e2fc814556d6a91
15 changes: 7 additions & 8 deletions modules/queue/unique_queue_channel.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,13 @@ func NewChannelUniqueQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue
}
queue.WorkerPool = NewWorkerPool(func(data ...Data) {
for _, datum := range data {
bs, err := json.Marshal(datum)
if err != nil {
log.Error("unable to marshal data: %v", datum)
} else {
queue.lock.Lock()
delete(queue.table, string(bs))
queue.lock.Unlock()
}
// No error is possible here because PushFunc ensures that this can be marshalled
bs, _ := json.Marshal(datum)

queue.lock.Lock()
delete(queue.table, string(bs))
queue.lock.Unlock()

handle(datum)
}
}, config.WorkerPoolConfiguration)
Expand Down