Class: PipelineToolkit::CLI::MsgSubscribeCLI

Inherits:
Object
  • Object
show all
Defined in:
lib/pipeline_toolkit/cli/msg_subscribe_cli.rb

Class Method Summary collapse

Class Method Details

.execute(stdout, arguments = []) ⇒ Object



9
10
11
12
13
14
15
16
17
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/pipeline_toolkit/cli/msg_subscribe_cli.rb', line 9

def self.execute(stdout, arguments=[])

  opts = Trollop::options do
    banner <<-EOL
Message Subscriber
------------------
  Subscribe to a Message Queue server using AMQP and pass messages to the next worker.

  Usage:
  msg_subscribe [options]

Examples:
  msg_subscribe --name octane_message_formatter --port 8000  \\
          --queue us_stocks
  msg_subscribe --exchange octane --type topic --queue us_stocks \\
          --host www.domain.com --port 7000

Options:
EOL

    banner <<-EOL

  Queue/exchange:
EOL
    opt :exchange, "The exchange name", :type => :string, :required => true, :short => :x
    opt :type, "The exchange type (direct, fanout or topic)", :default => "fanout", :short => :t
    opt :passive, "If set to true, the server will not create the exchange if it does not already exist.", :default => false, :short => :s
    opt :durable, "If set to true, the exchange will be marked as durable.", :default => false, :short => :d
    opt :queue, "The destination queue (queue:routing_key). Routing keys will be ignored if exchange type is not topic.", :short => :q, :type => :string, :required => true
    opt :no_acks, "If flag is set then the server does not use acknowledgments for messages.", :type => :flag

    banner <<-EOL

  AMQP server:
EOL
    opt :host, "The AMQP message server host", :default => "localhost", :short => :h
    opt :port, "The AMQP message server port", :default => 5672, :short => :p
    opt :user, "The AMQP message server username", :default => "guest", :short => :u
    opt :pass, "The AMQP message server username", :default => "guest", :short => :w
    opt :vhost, "The AMQP message server vhost", :default => "/", :short => :v
      
    banner <<-EOL

  Monitoring:
EOL
    opt :http_port, "The port the HTTP monitoring interface runs on. A value must be given to enable the monitoring interface - by default the monitoring interface isn't enabled. An HTML or JSON response can be obtained by suffixing either .html or .json to the request", :type => :integer, :short => :o
                
    banner <<-EOL

  Misc:
EOL
    opt :pid_path, "Specifies a path to write a file containing the pid to, by default no pid file is created", :type => :string
    opt :log_conf, "YML file to configure logging", :short => :l, :type => :string, :required => false
    opt :env, "The environment to run (development, production)", :default => "development", :short => :e
  end

  MessageSubscriber.new(opts).start
end