Skip to content

Commit

Permalink
Improve implementation of the EnableFallback configuration option
Browse files Browse the repository at this point in the history
This goes back to the simple if and an early return when the option isn't enabled.
  • Loading branch information
annismckenzie committed Jan 7, 2024
1 parent ddda866 commit 7fa1b92
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pubsub/gochannel/pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,15 @@ func (g *GoChannel) sendMessage(topic string, message *message.Message) (<-chan

logFields := watermill.LogFields{"message_uuid": message.UUID, "topic": topic}

switch {
case len(subscribers) == 0 && g.config.EnableFallback:
if len(subscribers) == 0 {
if !g.config.EnableFallback {
return g.handleNoSubscribers(ackedBySubscribers, logFields)
}

g.logger.Debug("No subscribers to send the message to, trying the fallback subscribers", logFields)
subscribers = g.topicSubscribers(NoSubscribersFallbackTopic)
if len(subscribers) == 0 {
if subscribers = g.topicSubscribers(NoSubscribersFallbackTopic); len(subscribers) == 0 {
return g.handleNoSubscribers(ackedBySubscribers, logFields)
}
case len(subscribers) == 0:
return g.handleNoSubscribers(ackedBySubscribers, logFields)
}

go func(subscribers []*subscriber) {
Expand Down

0 comments on commit 7fa1b92

Please sign in to comment.