Skip to content

Commit

Permalink
goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhorsey committed Sep 20, 2023
1 parent 34d8964 commit 23e35ea
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions packages/relayer/processor/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,25 +289,27 @@ func (p *Processor) eventLoop(ctx context.Context) {
case <-ctx.Done():
return
case msg := <-p.msgCh:
err := p.processMessage(ctx, msg)

if err != nil {
slog.Error("err processing message", "err", err.Error())

if errors.Is(err, errUnprocessable) {
if err := p.queue.Ack(ctx, msg); err != nil {
slog.Error("Err acking message", "err", err.Error())
go func(msg queue.Message) {
err := p.processMessage(ctx, msg)

if err != nil {
slog.Error("err processing message", "err", err.Error())

if errors.Is(err, errUnprocessable) {
if err := p.queue.Ack(ctx, msg); err != nil {
slog.Error("Err acking message", "err", err.Error())
}
} else {
if err := p.queue.Nack(ctx, msg); err != nil {
slog.Error("Err nacking message", "err", err.Error())
}
}
} else {
if err := p.queue.Nack(ctx, msg); err != nil {
slog.Error("Err nacking message", "err", err.Error())
if err := p.queue.Ack(ctx, msg); err != nil {
slog.Error("Err acking message", "err", err.Error())
}
}
} else {
if err := p.queue.Ack(ctx, msg); err != nil {
slog.Error("Err acking message", "err", err.Error())
}
}
}(msg)
}
}
}

0 comments on commit 23e35ea

Please sign in to comment.