class MQBench::Options
Constants
- MANDATORY_OPTS
Attributes
conf[R]
Public Class Methods
new(argv)
click to toggle source
# File lib/mqbench/options.rb, line 9 def initialize(argv) @opt = OptionParser.new @conf = {} @opt.on("-m m", "--mode m", "[mandatory] broker type {amqp|stomp|kafka}") {|v| @conf[:mode] = v} @opt.on("-s s", "--size s", "[mandatory] message size (bytes)") {|v| @conf[:size] = v.to_i} @opt.on("-c c", "--count c", "[mandatory] message counts") {|v| @conf[:count] = v.to_i} @opt.on("-u u", "--user p", "specify user-id to login broker") {|v| @conf[:user] = v} @opt.on("-w w", "--pass w", "specify password to login broker") {|v| @conf[:pass] = v} @opt.on("-h h", "--host h", "specify host where broker is running") {|v| @conf[:host] = v} @opt.on("-p p", "--port p", "specify TCP port-number which broker listens") {|v| @conf[:port] = v.to_i} begin @opt.parse!(argv) rescue OptionParser::MissingArgument => e puts @opt.help exit 1 end end
Public Instance Methods
is_valid?()
click to toggle source
# File lib/mqbench/options.rb, line 29 def is_valid? not MANDATORY_OPTS.map {|x| @conf.key? x}.include?(false) end
show_usage()
click to toggle source
# File lib/mqbench/options.rb, line 33 def show_usage puts @opt.help end