Sha256: 33162e2a8c30f1a81ec7e9cd0d608a151cc194d8a248d936b074c7d1c6d328cd
Contents?: true
Size: 1.61 KB
Versions: 3
Compression:
Stored size: 1.61 KB
Contents
module RedisFailover # Parses server command-line arguments. class CLI def self.parse(source) return {} if source.empty? options = {} parser = OptionParser.new do |opts| opts.banner = "Usage: redis_node_manager [OPTIONS]" opts.on('-p', '--password password', 'Redis password (optional)') do |password| options[:password] = password.strip end opts.on('-n', '--nodes redis nodes', 'Comma-separated redis host:port pairs (required)') do |nodes| # turns 'host1:port,host2:port' => [{:host => host, :port => port}, ...] options[:nodes] = nodes.split(',').map do |node| Hash[[:host, :port].zip(node.strip.split(':'))] end end opts.on('-z', '--zkservers zookeeper servers', 'Comma-separated zookeeper host:port pairs (required)') do |servers| options[:zkservers] = servers end opts.on('--znode-path path', 'Znode path override for storing redis server list (optional)') do |path| options[:znode_path] = path end opts.on('--max-failures count', 'Max failures before manager marks node unavailable (default 3)') do |max| options[:max_failures] = Integer(max) end opts.on('-h', '--help', 'Display all options') do puts opts exit end end parser.parse(source) # assume password is same for all redis nodes if password = options[:password] options[:nodes].each { |opts| opts.update(:password => password) } end options end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
redis_failover-0.5.2 | lib/redis_failover/cli.rb |
redis_failover-0.5.1 | lib/redis_failover/cli.rb |
redis_failover-0.5.0 | lib/redis_failover/cli.rb |