Class: Thor::Jobs::Node
- Inherits:
-
Thor::Job
- Object
- Bsl::Application
- Application
- Thor::Job
- Thor::Jobs::Node
- Defined in:
- lib/jobs/Node-0.0.1/main.rb
Constant Summary collapse
- @@AUTHOR =
"[email protected]"
- @@DESCRIPTION =
"Core node functionality"
- @@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 = {}) ⇒ Node
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 = {}) ⇒ Node
C-tor
13 14 15 |
# File 'lib/jobs/Node-0.0.1/main.rb', line 13 def initialize(opts = {}) super(opts) end |
Instance Method Details
#main ⇒ Object
Console application main()
51 52 53 |
# File 'lib/jobs/Node-0.0.1/main.rb', line 51 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 |
# File 'lib/jobs/Node-0.0.1/main.rb', line 18 def run(opts = {}) super(opts) if([:verbose]) Bsl::Logger::Log "Thor::Jobs::Node::run()" end =begin # Construct queue name klass_name = (self.class.name + "s").downcase queue_name = klass_name + "." + Thor::generate_guid channel = AMQP::Channel.new(amqp_conn) exchange = channel.fanout(klass_name) channel.queue("#{rand(100)}", :auto_delete => true).bind(exchange).subscribe do |payload| # Bsl::Logger::Log "#{payload} => joe" end channel.queue("#{rand(100)}", :auto_delete => true).bind(exchange).subscribe do |payload| # Bsl::Logger::Log "#{payload} => aaron" end channel.queue("#{rand(100)}", :auto_delete => true).bind(exchange).subscribe do |payload| # Bsl::Logger::Log "#{payload} => bob" end EventMachine.add_periodic_timer(0) do exchange.publish("BOS 101, NYK 89").publish("ORL 85, ALT 88") end =end end |