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 79bdde1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions extras/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ tcp_proxy_protocol = false
tls_port = 5671
unix_path = /tmp/lavinmq.sock
unix_proxy_protocol = true

[replication]
bind = 0.0.0.0
port = 5679
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 79bdde1

Please sign in to comment.