Class: RedisRing::SlaveRPC::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/redis_ring/slave_rpc.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hostObject (readonly)

Returns the value of attribute host.



16
17
18
# File 'lib/redis_ring/slave_rpc.rb', line 16

def host
  @host
end

#http_clientObject (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

#portObject (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

#joinObject



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

#statusObject



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