mirror of
https://github.com/discourse/discourse.git
synced 2025-06-01 06:09:15 +08:00
Revert "Something here is messed up Revert "message bus fixes and diagnostics""
This reverts commit f3c6144e3b66cadce9a0970c7d8437091b895117.
This commit is contained in:
32
lib/message_bus_diags.rb
Normal file
32
lib/message_bus_diags.rb
Normal file
@ -0,0 +1,32 @@
|
||||
class MessageBusDiags
|
||||
|
||||
@host_info = {}
|
||||
|
||||
def self.my_id
|
||||
@my_id ||= "#{`hostname`}-#{Process.pid}"
|
||||
end
|
||||
|
||||
def self.seen_host(name)
|
||||
@host_info[name] = DateTime.now
|
||||
end
|
||||
|
||||
def self.establish_peer_names
|
||||
MessageBus.publish "/server-name", {channel: "/server-name-reply/#{my_id}"}
|
||||
end
|
||||
|
||||
def self.seen_hosts
|
||||
@host_info
|
||||
end
|
||||
|
||||
unless @subscribed
|
||||
|
||||
MessageBus.subscribe "/server-name-reply/#{my_id}" do |msg|
|
||||
MessageBusDiags.seen_host(msg.data)
|
||||
end
|
||||
|
||||
MessageBus.subscribe "/server-name" do |msg|
|
||||
MessageBus.publish msg.data["channel"], MessageBusDiags.my_id
|
||||
end
|
||||
@subscribed = true
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user