Sha256: 1c740ea600f0c77ce131da3dc38d179bb20e51e0cd43086cac0b4813c583790e

Contents?: true

Size: 1.04 KB

Versions: 13

Compression:

Stored size: 1.04 KB

Contents

module RedisFailover
  # Base class for strategies that determine node availability.
  class NodeStrategy
    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/node_strategy/#{name.downcase}"
      const_get(name.capitalize).new
    rescue LoadError, NameError
      raise "Failed to find node strategy: #{name}"
    end

    # Returns the state determined by this strategy.
    #
    # @param [Node] the node to handle
    # @param [Hash<Node, NodeSnapshot>] snapshots the current set of snapshots
    # @return [Symbol] the status
    def determine_state(node, snapshots)
      raise NotImplementedError
    end

    # Logs a node as being unavailable.
    #
    # @param [Node] node the node
    # @param [NodeSnapshot] snapshot the node snapshot
    def log_unavailable(node, snapshot)
      logger.info("#{self.class} marking #{node} as unavailable. Snapshot: #{snapshot}")
    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/node_strategy.rb
nogara-redis_failover-1.0.6 lib/redis_failover/node_strategy.rb
nogara-redis_failover-1.0.5 lib/redis_failover/node_strategy.rb
nogara-redis_failover-1.0.4 lib/redis_failover/node_strategy.rb
redis_failover-1.0.2 lib/redis_failover/node_strategy.rb
nogara-redis_failover-1.0.2 lib/redis_failover/node_strategy.rb
nogara-redis_failover-1.0.1 lib/redis_failover/node_strategy.rb
redis_failover-1.0.1 lib/redis_failover/node_strategy.rb
nogara-redis_failover-1.0.0 lib/redis_failover/node_strategy.rb
redis_failover-1.0.0 lib/redis_failover/node_strategy.rb
nogara-redis_failover-0.9.7.4 lib/redis_failover/node_strategy.rb
nogara-redis_failover-0.9.7.3 lib/redis_failover/node_strategy.rb
nogara-redis_failover-0.9.7.2 lib/redis_failover/node_strategy.rb