Class: RedisFailover::FailoverStrategy

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/redis_failover/failover_strategy.rb,
lib/redis_failover/failover_strategy/latency.rb

Overview

Base class for strategies that determine which node is used during failover.

Direct Known Subclasses

Latency

Defined Under Namespace

Classes: Latency

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

Instance Method Summary collapse

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.

Parameters:

  • name (String, Symbol)

    the strategy name

Returns:

  • (Object)

    a new strategy instance



10
11
12
13
14
15
# File 'lib/redis_failover/failover_strategy.rb', line 10

def self.for(name)
  require "redis_failover/failover_strategy/#{name.downcase}"
  const_get(name.capitalize).new
rescue LoadError, NameError
  raise "Failed to find failover strategy: #{name}"
end

Instance Method Details

#find_candidate(snapshots) ⇒ Node

Returns a candidate node as determined by this strategy.

Parameters:

Returns:

  • (Node)

    the candidate node or nil if one couldn't be found

Raises:

  • (NotImplementedError)


21
22
23
# File 'lib/redis_failover/failover_strategy.rb', line 21

def find_candidate(snapshots)
  raise NotImplementedError
end