Class: Dalli::Elasticache::AutoDiscovery::ConfigCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- Dalli::Elasticache::AutoDiscovery::ConfigCommand
- Defined in:
- lib/dalli/elasticache/auto_discovery/config_command.rb
Overview
Encapsulates execution of the ‘config’ command, which is used to extract the list of nodes and determine if that list of nodes has changed.
Constant Summary collapse
- CONFIG_COMMAND =
"config get cluster\r\n"
- LEGACY_CONFIG_COMMAND =
Legacy command for version < 1.4.14
"get AmazonElastiCache:cluster\r\n"
Instance Attribute Summary collapse
-
#engine_version ⇒ Object
readonly
Returns the value of attribute engine_version.
Attributes inherited from BaseCommand
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(host, port, engine_version) ⇒ ConfigCommand
constructor
A new instance of ConfigCommand.
- #legacy_config? ⇒ Boolean
- #response ⇒ Object
Methods inherited from BaseCommand
#response_from_socket, #send_command
Constructor Details
#initialize(host, port, engine_version) ⇒ ConfigCommand
Returns a new instance of ConfigCommand.
18 19 20 21 |
# File 'lib/dalli/elasticache/auto_discovery/config_command.rb', line 18 def initialize(host, port, engine_version) super(host, port) @engine_version = engine_version end |
Instance Attribute Details
#engine_version ⇒ Object (readonly)
Returns the value of attribute engine_version.
11 12 13 |
# File 'lib/dalli/elasticache/auto_discovery/config_command.rb', line 11 def engine_version @engine_version end |
Instance Method Details
#command ⇒ Object
27 28 29 30 31 |
# File 'lib/dalli/elasticache/auto_discovery/config_command.rb', line 27 def command return LEGACY_CONFIG_COMMAND if legacy_config? CONFIG_COMMAND end |
#legacy_config? ⇒ Boolean
33 34 35 36 37 38 39 40 41 |
# File 'lib/dalli/elasticache/auto_discovery/config_command.rb', line 33 def legacy_config? return false unless engine_version return false if engine_version.casecmp('unknown').zero? Gem::Version.new(engine_version) < Gem::Version.new('1.4.14') rescue ArgumentError # Just assume false if we can't parse the engine_version false end |
#response ⇒ Object
23 24 25 |
# File 'lib/dalli/elasticache/auto_discovery/config_command.rb', line 23 def response ConfigResponse.new(send_command) end |