Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
runabol committed Jul 27, 2023
1 parent f2bbd90 commit 43095af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions broker/inmemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,14 @@ func (b *InMemoryBroker) Send(ctx context.Context, qname string, t task.Task) er

func (b *InMemoryBroker) Receive(qname string, handler func(ctx context.Context, t task.Task) error) error {
log.Debug().Msgf("subscribing for tasks on %s", qname)
b.mu.Lock()
defer b.mu.Unlock()
b.mu.RLock()
q, ok := b.queues[qname]
b.mu.RUnlock()
if !ok {
q = make(chan task.Task, 10)
b.mu.Lock()
b.queues[qname] = q
b.mu.Unlock()
}
go func() {
ctx := context.TODO()
Expand Down

0 comments on commit 43095af

Please sign in to comment.