Class: RedisFailover::NodeStrategy
- Inherits:
-
Object
- Object
- RedisFailover::NodeStrategy
- Includes:
- Util
- Defined in:
- lib/redis_failover/node_strategy.rb,
lib/redis_failover/node_strategy/single.rb,
lib/redis_failover/node_strategy/majority.rb,
lib/redis_failover/node_strategy/consensus.rb
Overview
Base class for strategies that determine node availability.
Defined Under Namespace
Classes: Consensus, Majority, Single
Constant Summary
Constants included from Util
Util::CONNECTIVITY_ERRORS, Util::DEFAULT_ROOT_ZNODE_PATH, Util::REDIS_ERRORS, Util::REDIS_READ_OPS, Util::UNSUPPORTED_OPS, Util::ZK_ERRORS
Class Method Summary collapse
-
.for(name) ⇒ Object
Loads a strategy based on the given name.
Instance Method Summary collapse
-
#determine_state(node, snapshots) ⇒ Symbol
Returns the state determined by this strategy.
-
#log_unavailable(node, snapshot) ⇒ Object
Logs a node as being unavailable.
Methods included from Util
#decode, #different?, #encode, logger, #logger, logger=, #symbolize_keys
Class Method Details
.for(name) ⇒ Object
Loads a strategy based on the given name.
10 11 12 13 14 15 |
# File 'lib/redis_failover/node_strategy.rb', line 10 def self.for(name) require "redis_failover/node_strategy/#{name.downcase}" const_get(name.capitalize).new rescue LoadError, NameError raise "Failed to find node strategy: #{name}" end |
Instance Method Details
#determine_state(node, snapshots) ⇒ Symbol
Returns the state determined by this strategy.
22 23 24 |
# File 'lib/redis_failover/node_strategy.rb', line 22 def determine_state(node, snapshots) raise NotImplementedError end |
#log_unavailable(node, snapshot) ⇒ Object
Logs a node as being unavailable.
30 31 32 |
# File 'lib/redis_failover/node_strategy.rb', line 30 def log_unavailable(node, snapshot) logger.info("#{self.class} marking #{node} as unavailable. Snapshot: #{snapshot}") end |