Sha256: b78999a8e63cbdd63e97901e199f6c6e7d2615f3a72d05bd86ff3caa10407fc9
Contents?: true
Size: 1.33 KB
Versions: 4
Compression:
Stored size: 1.33 KB
Contents
module RedisRing class WebInterfaceRunner include RedisRing::BackgroundThread attr_reader :master, :slave def initialize(port, master, slave) @port = port @master = master @slave = slave end def do_work handler = Rack::Handler.get("webrick") handler.run(WebInterface, :Port => @port, :master => @master, :slave => @slave) do |server| @server = server WebInterface.set :master, master WebInterface.set :slave, slave WebInterface.set :running, true end end def halt super @server.stop if @server end end class WebInterface < Sinatra::Base def master self.class.master end def slave self.class.slave end get "/" do "RedisRing is running" end post "/master/node_joined/:node_id" do master.node_joined(params[:node_id]) "OK" end get "/slave/status" do content_type :json slave.status.to_json end post "/slave/join" do slave.join "OK" end post "/slave/start_shard/:shard_no" do slave.start_shard(params[:shard_no].to_i) "OK" end post "/slave/stop_shard/:shard_no" do slave.stop_shard(params[:shard_no].to_i) "OK" end class << self attr_accessor :master, :slave end end end
Version data entries
4 entries across 4 versions & 1 rubygems