Class: AppAmqp2Sql
- Inherits:
-
Thor::Application
- Object
- Bsl::Application
- Thor::Application
- AppAmqp2Sql
- Defined in:
- app/amqp2sql.rb
Instance Attribute Summary
Attributes inherited from Thor::Application
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ AppAmqp2Sql
constructor
A new instance of AppAmqp2Sql.
- #main ⇒ Object
Methods inherited from Thor::Application
#amqp_handle_failure, #amqp_loop, #amqp_start, #amqp_stop, #run
Constructor Details
#initialize(opts = {}) ⇒ AppAmqp2Sql
Returns a new instance of AppAmqp2Sql.
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/amqp2sql.rb', line 21 def initialize(opts = {}) super(opts) # AMQP options [:amqp] = {} [:amqp][:host] = "localhost" [:amqp][:port] = 8467 [:amqp][:user] = "guest" [:amqp][:password] = "guest" [:amqp][:vhost] = "/" [:sql] = {} [:sql][:host] = "localhost" [:sql][:port] = 5432 [:sql][:user] = "guest" [:sql][:password] = "guest" initialize_optparser { |opts| # AMQP Host opts.on( '--amqp-host STRING', "AMQP Server hostname [default: #{[:amqp][:host]}]") do |host| [:amqp][:host] = host end # AMQP Port opts.on('--amqp-port NUM', "AMQP Server port number [default: #{[:amqp][:port]}]") do |port| [:amqp][:port] = port end # AMQP Username opts.on('--amqp-user STRING', "AMQP Username [default: #{[:amqp][:user]}]") do |user| [:amqp][:user] = user end # AMQP Password opts.on('--amqp-password STRING', "AMQP Password [default: #{[:amqp][:password]}]") do |password| [:amqp][:password] = password end # AMQP Vhost opts.on('--amqp-vhost STRING', "AMQP Virtual Host [default: #{[:amqp][:vhost]}]") do |vhost| [:amqp][:vhost] = vhost end # SQL Host opts.on( '--sql-host STRING', "PostgreSQL Server hostname [default: #{[:sql][:host]}]") do |host| [:sql][:host] = host end # SQL Port opts.on('--sql-port NUM', "PostgreSQL Server port number [default: #{[:sql][:port]}]") do |port| [:sql][:port] = port end # SQL Username opts.on('--sql-user STRING', "PostgreSQL Username [default: #{[:sql][:user]}]") do |user| [:sql][:user] = user end # SQL Password opts.on('--sql-password STRING', "PostgreSQL Password [default: #{[:sql][:password]}]") do |password| [:sql][:password] = password end } end |
Instance Method Details
#main ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'app/amqp2sql.rb', line 86 def main super() # Run loop while exit is not requested while(request_exit == false) begin amqp_start() rescue SystemExit, Interrupt Bsl::Logger::Log "Received interrupt, quitting!" @request_exit = true amqp_stop() rescue Exception => e amqp_handle_failure(e) end puts "." end end |