Class: RedisRing::SlaveRPC::Connection
- Inherits:
-
Object
- Object
- RedisRing::SlaveRPC::Connection
- Defined in:
- lib/redis_ring/slave_rpc.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(http_client, host, port) ⇒ Connection
constructor
A new instance of Connection.
- #join ⇒ Object
- #start_shard(shard_no) ⇒ Object
- #status ⇒ Object
- #stop_shard(shard_no) ⇒ Object
Constructor Details
#initialize(http_client, host, port) ⇒ Connection
Returns a new instance of Connection.
18 19 20 21 22 |
# File 'lib/redis_ring/slave_rpc.rb', line 18 def initialize(http_client, host, port) @http_client = http_client @host = host @port = port end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
16 17 18 |
# File 'lib/redis_ring/slave_rpc.rb', line 16 def host @host end |
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
16 17 18 |
# File 'lib/redis_ring/slave_rpc.rb', line 16 def http_client @http_client end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
16 17 18 |
# File 'lib/redis_ring/slave_rpc.rb', line 16 def port @port end |
Instance Method Details
#join ⇒ Object
24 25 26 |
# File 'lib/redis_ring/slave_rpc.rb', line 24 def join http_client.post(host, port, "/slave/join") end |
#start_shard(shard_no) ⇒ Object
32 33 34 |
# File 'lib/redis_ring/slave_rpc.rb', line 32 def start_shard(shard_no) http_client.post(host, port, "/slave/start_shard/#{shard_no}") end |
#status ⇒ Object
28 29 30 |
# File 'lib/redis_ring/slave_rpc.rb', line 28 def status JSON.parse(http_client.get(host, port, "/slave/status")) end |
#stop_shard(shard_no) ⇒ Object
36 37 38 |
# File 'lib/redis_ring/slave_rpc.rb', line 36 def stop_shard(shard_no) http_client.post(host, port, "/slave/stop_shard/#{shard_no}") end |