Sha256: e71bb5a4f4eab398157615136ac6feee49bcf9e45316b6df1534b8a7efbd6436

Contents?: true

Size: 627 Bytes

Versions: 13

Compression:

Stored size: 627 Bytes

Contents

module RedisFailover
  class FailoverStrategy
    # Failover strategy that selects an available node that is both seen by all
    # node managers and has the lowest reported health check latency.
    class Latency < FailoverStrategy
      # @see RedisFailover::FailoverStrategy#find_candidate
      def find_candidate(snapshots)
        candidates = {}
        snapshots.each do |node, snapshot|
          if snapshot.all_available?
            candidates[node] = snapshot.avg_latency
          end
        end

        if candidate = candidates.min_by(&:last)
          candidate.first
        end
      end
    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/latency.rb
nogara-redis_failover-1.0.6 lib/redis_failover/failover_strategy/latency.rb
nogara-redis_failover-1.0.5 lib/redis_failover/failover_strategy/latency.rb
nogara-redis_failover-1.0.4 lib/redis_failover/failover_strategy/latency.rb
redis_failover-1.0.2 lib/redis_failover/failover_strategy/latency.rb
nogara-redis_failover-1.0.2 lib/redis_failover/failover_strategy/latency.rb
nogara-redis_failover-1.0.1 lib/redis_failover/failover_strategy/latency.rb
redis_failover-1.0.1 lib/redis_failover/failover_strategy/latency.rb
nogara-redis_failover-1.0.0 lib/redis_failover/failover_strategy/latency.rb
redis_failover-1.0.0 lib/redis_failover/failover_strategy/latency.rb
nogara-redis_failover-0.9.7.4 lib/redis_failover/failover_strategy/latency.rb
nogara-redis_failover-0.9.7.3 lib/redis_failover/failover_strategy/latency.rb
nogara-redis_failover-0.9.7.2 lib/redis_failover/failover_strategy/latency.rb