Class: Dalli::Elasticache::AutoDiscovery::Endpoint
- Inherits:
-
Object
- Object
- Dalli::Elasticache::AutoDiscovery::Endpoint
- Defined in:
- lib/dalli/elasticache/auto_discovery/endpoint.rb
Overview
This is a representation of the configuration endpoint for a memcached cluster. It encapsulates information returned from that endpoint.
Constant Summary collapse
- ENDPOINT_REGEX =
Matches Strings like “my-host.cache.aws.com:11211”
/^([-_.a-zA-Z0-9]+)(?::(\d+))?$/.freeze
- DEFAULT_PORT =
11_211
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Endpoint configuration.
-
#port ⇒ Object
readonly
Endpoint configuration.
Instance Method Summary collapse
-
#config ⇒ Object
A cached ElastiCache::ConfigResponse.
-
#engine_version ⇒ Object
The memcached engine version.
-
#initialize(addr) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #parse_endpoint_address(addr) ⇒ Object
-
#stats ⇒ Object
A cached ElastiCache::StatsResponse.
Constructor Details
#initialize(addr) ⇒ Endpoint
Returns a new instance of Endpoint.
18 19 20 |
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 18 def initialize(addr) @host, @port = parse_endpoint_address(addr) end |
Instance Attribute Details
#host ⇒ Object (readonly)
Endpoint configuration
13 14 15 |
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 13 def host @host end |
#port ⇒ Object (readonly)
Endpoint configuration
13 14 15 |
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 13 def port @port end |
Instance Method Details
#config ⇒ Object
A cached ElastiCache::ConfigResponse
36 37 38 |
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 36 def config @config ||= ConfigCommand.new(@host, @port, engine_version).response end |
#engine_version ⇒ Object
The memcached engine version
41 42 43 |
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 41 def engine_version stats.engine_version end |
#parse_endpoint_address(addr) ⇒ Object
23 24 25 26 27 28 |
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 23 def parse_endpoint_address(addr) m = ENDPOINT_REGEX.match(addr) raise ArgumentError, "Unable to parse configuration endpoint address - #{addr}" unless m [m[1], (m[2] || DEFAULT_PORT).to_i] end |
#stats ⇒ Object
A cached ElastiCache::StatsResponse
31 32 33 |
# File 'lib/dalli/elasticache/auto_discovery/endpoint.rb', line 31 def stats @stats ||= StatsCommand.new(@host, @port).response end |