Sha256: d5ece4a09503b517f340a511a4d1b88313764c739070964bc05cfcd3bbdbc0e9

Contents?: true

Size: 816 Bytes

Versions: 13

Compression:

Stored size: 816 Bytes

Contents

module RedisFailover
  # Base class for strategies that determine which node is used during failover.
  class FailoverStrategy
    include Util

    # Loads a strategy based on the given name.
    #
    # @param [String, Symbol] name the strategy name
    # @return [Object] a new strategy instance
    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

    # Returns a candidate node as determined by this strategy.
    #
    # @param [Hash<Node, NodeSnapshot>] snapshots the node snapshots
    # @return [Node] the candidate node or nil if one couldn't be found
    def find_candidate(snapshots)
      raise NotImplementedError
    end
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
spbtv_redis_failover-1.0.2.1 lib/redis_failover/failover_strategy.rb
nogara-redis_failover-1.0.6 lib/redis_failover/failover_strategy.rb
nogara-redis_failover-1.0.5 lib/redis_failover/failover_strategy.rb
nogara-redis_failover-1.0.4 lib/redis_failover/failover_strategy.rb
redis_failover-1.0.2 lib/redis_failover/failover_strategy.rb
nogara-redis_failover-1.0.2 lib/redis_failover/failover_strategy.rb
nogara-redis_failover-1.0.1 lib/redis_failover/failover_strategy.rb
redis_failover-1.0.1 lib/redis_failover/failover_strategy.rb
nogara-redis_failover-1.0.0 lib/redis_failover/failover_strategy.rb
redis_failover-1.0.0 lib/redis_failover/failover_strategy.rb
nogara-redis_failover-0.9.7.4 lib/redis_failover/failover_strategy.rb
nogara-redis_failover-0.9.7.3 lib/redis_failover/failover_strategy.rb
nogara-redis_failover-0.9.7.2 lib/redis_failover/failover_strategy.rb