Sha256: 90debef798c0cd24cb4680f62b52123c792f77bd4aea9259050a599e1eb88abc

Contents?: true

Size: 1.24 KB

Versions: 8

Compression:

Stored size: 1.24 KB

Contents

#!/usr/bin/env ruby
# encoding: utf-8

require 'rubygems'
require 'bundler/setup'
require 'tengine_event'
require 'optparse'

# MQ のための最低限の設定のみ
cfg = Hash.new
qn = nil
op = OptionParser.new $0 do |this|
  # tengined compatible option names.
  this.on '-o host', '--event-queue-connection-host=host', 'where to connect' do |arg| cfg[:host] = arg end
  this.on '-p port', '--evant-queue-connection-port=port', 'where to connect', Integer do |arg| cfg[:port] = arg end
  this.on '-u user', '--evant-queue-connection-user=user', 'whom to connect' do |arg| cfg[:user] = arg end
  this.on '-s pass', '--evant-queue-connection-pass=pass', 'whom to connect' do |arg| cfg[:pass] = arg end
  this.on '-q queue', '--evant-queue-connection-queue=queue', 'what to connect' do |arg| qn = arg end
end

op.parse! ARGV

hash = { :connection => cfg }
hash[:queue] = { :name => qn } if qn
suite = Tengine::Mq::Suite.new hash

# main loop
EM.run do
  i = 0
  j = false
  suite.subscribe :confirm => proc{j = true} do |hdr, bdy|
    hdr.ack
    STDOUT.puts bdy
    i += 1
  end
  timer = EM.add_periodic_timer 0.1 do
    if j and i.zero?
      EM.cancel_timer timer
      suite.unsubscribe do
        suite.stop
      end
    else
      i = 0
    end
  end
end

Process.exit true

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
tengine_event-1.2.2 bin/tengine_event_sucks
tengine_event-1.2.1 bin/tengine_event_sucks
tengine_event-1.2.0 bin/tengine_event_sucks
tengine_event-1.1.0 bin/tengine_event_sucks
tengine_event-0.4.9 bin/tengine_event_sucks
tengine_event-0.4.8 bin/tengine_event_sucks
tengine_event-0.4.7 bin/tengine_event_sucks
tengine_event-0.4.6 bin/tengine_event_sucks