lib/redis_failover/cli.rb in redis_failover-0.9.7.2 vs lib/redis_failover/cli.rb in redis_failover-1.0.0

- old
+ new

@@ -46,10 +46,25 @@ opts.on('-E', '--environment ENV', 'Config environment to use') do |config_env| options[:config_environment] = config_env end + opts.on('--node-strategy STRATEGY', + 'Strategy used when determining availability of nodes (default: majority)') do |strategy| + options[:node_strategy] = strategy + end + + opts.on('--failover-strategy STRATEGY', + 'Strategy used when failing over to a new node (default: latency)') do |strategy| + options[:failover_strategy] = strategy + end + + opts.on('--required-node-managers COUNT', + 'Required Node Managers that must be reachable to determine node state (default: 1)') do |count| + options[:required_node_managers] = Integer(count) + end + opts.on('-h', '--help', 'Display all options') do puts opts exit end end @@ -57,20 +72,20 @@ parser.parse(source) if config_file = options[:config_file] options = from_file(config_file, options[:config_environment]) end - if required_options_missing?(options) + if invalid_options?(options) puts parser exit end prepare(options) end # @return [Boolean] true if required options missing, false otherwise - def self.required_options_missing?(options) + def self.invalid_options?(options) return true if options.empty? return true unless options.values_at(:nodes, :zkservers).all? false end @@ -109,9 +124,17 @@ end # assume password is same for all redis nodes if password = options[:password] options[:nodes].each { |opts| opts.update(:password => password) } + end + + if node_strategy = options[:node_strategy] + options[:node_strategy] = node_strategy.to_sym + end + + if failover_strategy = options[:failover_strategy] + options[:failover_strategy] = failover_strategy.to_sym end options end end