Skip to content

Commit

Permalink
break max_lag loop if follower disconnects, and only check for min am…
Browse files Browse the repository at this point in the history
…ount of followers
  • Loading branch information
kickster97 committed Sep 27, 2023
1 parent f75405e commit e6ca908
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
2 changes: 0 additions & 2 deletions extras/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,3 @@ tcp_proxy_protocol = false
tls_port = 5671
unix_path = /tmp/lavinmq.sock
unix_proxy_protocol = true
min_followers = 1
max_lag = 10000
11 changes: 3 additions & 8 deletions src/lavinmq/replication/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,10 @@ module LavinMQ
select
when @wait_for_followers.receive
when timeout(1.seconds)
pp "Followers: #{@followers.size}"
end
end
#TODO: only start looping for max_lag for the amount min_followers
@followers.each do |f|
@followers.each_with_index do |f, i|
break if i > Config.instance.min_followers
f.wait_for_max_lag
end
end
Expand Down Expand Up @@ -240,15 +239,11 @@ module LavinMQ
if max_lag = Config.instance.max_lag
current_lag = lag
until current_lag < max_lag
pp "blocking: #{current_lag}"
select
when timeout(1.seconds)
pp lag
when current_lag = @ack.receive
end
pp "unblocking"
#TODO: break if THIS follower disconnects
break if @server.followers.size < Config.instance.min_followers
break if @server.followers.includes?(self) == false
end
end
end
Expand Down

0 comments on commit e6ca908

Please sign in to comment.