Sha256: 739446d954769fce67bfc2345686d832fe9db344936aa5a61ea50d7231a2afae
Contents?: true
Size: 1.19 KB
Versions: 4
Compression:
Stored size: 1.19 KB
Contents
module RedisRing class NodeProvider attr_reader :slave_rpc def initialize(slave_rpc) @slave_rpc = slave_rpc end def new(host, port) Node.new(slave_rpc.connection(host, port), host, port) end end class Node attr_reader :slave_rpc, :host, :port def initialize(slave_rpc, host, port) @slave_rpc = slave_rpc @host = host @port = port end def update_status! status_hash = slave_rpc.status @joined = status_hash["joined"] @running_shards = status_hash["running_shards"] || [] @available_shards = keys_to_i(status_hash["available_shards"] || {}) end def joined? @joined end def start_shard(shard_number) running_shards << shard_number slave_rpc.start_shard(shard_number) end def stop_shard(shard_number) running_shards.delete(shard_number) slave_rpc.stop_shard(shard_number) end def running_shards @running_shards ||= [] end def available_shards @available_shards ||= {} end protected def keys_to_i(hash) result = {} hash.each { |key, val| result[key.to_i] = val } return result end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
redis_ring-0.1.3 | lib/redis_ring/node.rb |
redis_ring-0.1.2 | lib/redis_ring/node.rb |
redis_ring-0.1.1 | lib/redis_ring/node.rb |
redis_ring-0.1.0 | lib/redis_ring/node.rb |