Class: Thor::Jobs::MonitorClient
- Inherits:
-
Thor::Job
- Object
- Bsl::Application
- Application
- Thor::Job
- Thor::Jobs::MonitorClient
- Defined in:
- lib/jobs/MonitorClient-0.0.1/main.rb
Constant Summary collapse
- @@AUTHOR =
"[email protected]"
- @@DESCRIPTION =
"Monitoring node"
- @@LICENSE =
"GPL"
- @@VERSION =
"0.0.1"
- @@SUPPORTED_MSGS =
[]
Instance Attribute Summary
Attributes inherited from Thor::Job
#amqp_conn, #em_conn, #sql_conn, #thread
Attributes inherited from Application
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ MonitorClient
constructor
C-tor.
-
#main ⇒ Object
Console application main().
-
#run(opts = {}) ⇒ Object
Async runner.
Methods inherited from Thor::Job
author, description, #is_running?, license, #process_msg, #start, #stop, supported_msgs, version
Methods inherited from Application
#amqp_handle_failure, #amqp_loop, #amqp_start, #amqp_stop
Constructor Details
#initialize(opts = {}) ⇒ MonitorClient
C-tor
13 14 15 |
# File 'lib/jobs/MonitorClient-0.0.1/main.rb', line 13 def initialize(opts = {}) super(opts) end |
Instance Method Details
#main ⇒ Object
Console application main()
69 70 71 |
# File 'lib/jobs/MonitorClient-0.0.1/main.rb', line 69 def main super() end |
#run(opts = {}) ⇒ Object
Async runner
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/jobs/MonitorClient-0.0.1/main.rb', line 18 def run(opts = {}) super(opts) if([:verbose]) Bsl::Logger::Log "Thor::Jobs::MonitorClient::run()" end # Construct channel response name channel_response_name = (self.class.name + ".response").downcase if([:channel_response] != nil) channel_response_name = [:channel_response] end # Create response channel if([:verbose]) Bsl::Logger::Log "Creating response channel - '#{channel_response_name}'" end channel_response = AMQP::Channel.new(amqp_conn) exchange_response = channel_response.fanout(channel_response_name) # Construct channel_request name channel_request_name = (self.class.name + ".request").downcase if([:channel_request] != nil) channel_request_name = [:channel_request] end queue_request_name = channel_request_name + "." + Thor::generate_guid # Create channel request if([:verbose]) Bsl::Logger::Log "Creating request channel - '#{channel_request_name}'" end channel_request = AMQP::Channel.new(amqp_conn) exchange_request = channel_request.fanout(channel_request_name) # Create and bind request queue if([:verbose]) Bsl::Logger::Log "Creating request queue - '#{queue_request_name}'" end channel_request.queue(queue_request_name, :auto_delete => true).bind(exchange_request).subscribe do |payload| if([:verbose]) Bsl::Logger::Log "Received payload: '#{payload}'" end process_msg(channel_request, exchange_request, payload) exchange_response.publish("Hi!") end end |