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

Bugfix: use next instead of return to continue listen for events #867

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
4 changes: 3 additions & 1 deletion src/lavinmq/clustering/controller.cr
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ class LavinMQ::Clustering::Controller
# Listens for leader change events
private def follow_leader
repli_client = nil
Log.info { "Listening for leader changes..." }
@etcd.elect_listen("#{@config.clustering_etcd_prefix}/leader") do |uri|
Log.debug { "Leader event: #{uri}" }
next if repli_client.try &.follows?(uri) # if lost connection to etcd we continue follow the leader as is
repli_client.try &.close
if uri == @advertised_uri # if this instance has become leader
Log.debug { "Is leader, don't replicate from self" }
return
next
end
Log.info { "Leader: #{uri}" }
key = "#{@config.clustering_etcd_prefix}/clustering_secret"
Expand Down
Loading