Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid starvation of NSQ event processing #66

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions internal/bmc/nsq.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ func (b *BMCService) InitConsumer() error {
MinVersion: tls.VersionTLS12,
}
config.TlsV1 = true
config.MaxInFlight = 100

consumer, err := nsq.NewConsumer(b.machineTopic, mqChannel, config)
if err != nil {
return err
}

consumer.SetLogger(nsqLogger{log: b.log}, nsqMapLevel(b.log))

consumer.AddHandler(b)

err = consumer.ConnectToNSQD(b.mqAddress)
Expand All @@ -70,7 +70,11 @@ func (b *BMCService) HandleMessage(message *nsq.Message) error {
return err
}

b.log.Debug("got message", "topic", b.machineTopic, "channel", mqChannel, "event", event)
if message.Attempts > 3 {
Gerrit91 marked this conversation as resolved.
Show resolved Hide resolved
b.log.Warn("ignoring message because of multiple failed attempts", "topic", b.machineTopic, "channel", mqChannel, "event", event, "attempts", message.Attempts)
return nil
}
b.log.Debug("got message", "topic", b.machineTopic, "channel", mqChannel, "event", event, "attempts", message.Attempts)

if event.Cmd.IPMI == nil {
return fmt.Errorf("event does not contain ipmi details:%v", event)
Expand Down