Sha256: 45df9d095cb38fe7247452c738c4fa16da4291aa6cad93997ff4bcd3a15fa2e6

Contents?: true

Size: 1.38 KB

Versions: 20

Compression:

Stored size: 1.38 KB

Contents

module RedisFailover
  class NodeManagerStub < NodeManager
    attr_accessor :master
    public :current_nodes

    def discover_nodes
      # only discover nodes once in testing
      return if @nodes_discovered

      master = Node.new(:host => 'master')
      slave = Node.new(:host => 'slave')
      [master, slave].each { |node| node.extend(RedisStubSupport) }
      master.make_master!
      slave.make_slave!(master)
      @unavailable = []
      @master = master
      @slaves = [slave]
      @nodes_discovered = true
    end

    def setup_zk
      @zk = NullObject.new
    end

    def slaves
      @slaves
    end

    def start_processing
      @thread = Thread.new { start }
      sleep(1.5)
    end

    def stop_processing
      @queue << nil
      @thread.value
    end

    def force_unavailable(node)
      start_processing
      node.redis.make_unavailable!
      notify_state(node, :unavailable)
      stop_processing
    end

    def force_available(node)
      start_processing
      node.redis.make_available!
      notify_state(node, :available)
      stop_processing
    end

    def force_syncing(node, serve_stale_reads)
      start_processing
      node.redis.force_sync_with_master(serve_stale_reads)
      notify_state(node, :syncing)
      stop_processing
    end

    def initialize_path; end
    def delete_path; end
    def create_path; end
    def write_state; end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
nogara-redis_failover-0.9.1 spec/support/node_manager_stub.rb
redis_failover-0.9.4 spec/support/node_manager_stub.rb
redis_failover-0.9.3 spec/support/node_manager_stub.rb
redis_failover-0.9.2 spec/support/node_manager_stub.rb
redis_failover-0.9.1 spec/support/node_manager_stub.rb
nogara-redis_failover-0.9.0 spec/support/node_manager_stub.rb
redis_failover-0.9.0 spec/support/node_manager_stub.rb
nogara-redis_failover-0.8.11 spec/support/node_manager_stub.rb
nogara-redis_failover-0.8.10 spec/support/node_manager_stub.rb
nogara-redis_failover-0.8.9 spec/support/node_manager_stub.rb
redis_failover-0.8.9 spec/support/node_manager_stub.rb
redis_failover-0.8.8 spec/support/node_manager_stub.rb
redis_failover-0.8.7 spec/support/node_manager_stub.rb
redis_failover-0.8.6 spec/support/node_manager_stub.rb
redis_failover-0.8.5 spec/support/node_manager_stub.rb
redis_failover-0.8.4 spec/support/node_manager_stub.rb
redis_failover-0.8.3 spec/support/node_manager_stub.rb
redis_failover-0.8.2 spec/support/node_manager_stub.rb
redis_failover-0.8.1 spec/support/node_manager_stub.rb
redis_failover-0.8.0 spec/support/node_manager_stub.rb