Skip to content

Commit

Permalink
server settings for replication
Browse files Browse the repository at this point in the history
  • Loading branch information
kickster97 committed Jul 12, 2023
1 parent debbf03 commit 5071009
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/lavinmq/replication/server.cr
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ module LavinMQ
@followers = Array(Follower).new
@password : String
@files = Hash(String, MFile?).new
@min_followers = 5_i64

def initialize
@password = password
Expand Down Expand Up @@ -98,6 +99,12 @@ module LavinMQ
end
end

def min_followers : Int64
@lock.synchronize do
@min_followers.dup # for thread safety
end
end

private def password : String
path = File.join(Config.instance.data_dir, ".replication_secret")
begin
Expand Down
3 changes: 3 additions & 0 deletions src/lavinmq/vhost.cr
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ module LavinMQ
headers = properties.headers
find_all_queues(ex, msg.routing_key, headers, visited, found_queues)
headers.try(&.delete("BCC"))
puts @replicator.min_followers
puts @replicator.followers.size
return false if @replicator.followers.size < @replicator.min_followers
# @log.debug { "publish queues#found=#{found_queues.size}" }
if found_queues.empty?
ex.unroutable_count += 1
Expand Down

0 comments on commit 5071009

Please sign in to comment.