Class: Dalli::Elasticache::AutoDiscovery::ConfigCommand

Inherits:
BaseCommand
  • Object
show all
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

Attributes inherited from BaseCommand

#host, #port

Instance Method Summary collapse

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_versionObject (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

#commandObject



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

Returns:

  • (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

#responseObject



23
24
25
# File 'lib/dalli/elasticache/auto_discovery/config_command.rb', line 23

def response
  ConfigResponse.new(send_command)
end