class Citrus::Master::WatchDog
Public Class Methods
new(app, console_service)
click to toggle source
Create a new watchdog
@param [Object] app @param [Object] console_service
# File lib/citrus/master/watchdog.rb, line 18 def initialize app, console_service @app = app @service = console_service @servers = {} @listeners = [] end
Public Instance Methods
add_server(server)
click to toggle source
Add server
@param [Hash] server
# File lib/citrus/master/watchdog.rb, line 28 def add_server server return unless server @servers[server[:server_id]] = server notify({ :action => 'add_server', :server => server }) end
query()
click to toggle source
Query
# File lib/citrus/master/watchdog.rb, line 57 def query @servers.values end
reconnect_server()
click to toggle source
Reconnect server
# File lib/citrus/master/watchdog.rb, line 39 def reconnect_server end
remove_server()
click to toggle source
Remove server
# File lib/citrus/master/watchdog.rb, line 35 def remove_server end
subscribe(server_id)
click to toggle source
Subscribe
@param [String] server_id
# File lib/citrus/master/watchdog.rb, line 45 def subscribe server_id @listeners << server_id end
unsubscribe(server_id)
click to toggle source
Unsubscribe
@param [String] server_id
# File lib/citrus/master/watchdog.rb, line 52 def unsubscribe server_id @listeners.delete server_id end
Private Instance Methods
notify(msg)
click to toggle source
Notify
@param [Hash] msg
@private
# File lib/citrus/master/watchdog.rb, line 68 def notify msg @listeners.each { |server_id| @service.agent.notify server_id, ConsoleModules::MonitorWatcher.module_id, msg } end
notify_by_id(server_id, msg)
click to toggle source
Notify
@param [String] server_id @param [Hash] msg
# File lib/citrus/master/watchdog.rb, line 78 def notify_by_id server_id, msg @service.agent.notify server_id, ConsoleModules::MonitorWatcher.module_id, msg end