Sha256: 339c055d857becf9e027cc44850b6c544be6ac9115ea7d013f80a40a1e9fe25a

Contents?: true

Size: 842 Bytes

Versions: 4

Compression:

Stored size: 842 Bytes

Contents

module RedisRing
  class SlaveRPC

    attr_reader :http_client

    def initialize(http_client)
      @http_client = http_client
    end

    def connection(host, port)
      Connection.new(http_client, host, port)
    end

    class Connection

      attr_reader :http_client, :host, :port

      def initialize(http_client, host, port)
        @http_client = http_client
        @host = host
        @port = port
      end

      def join
        http_client.post(host, port, "/slave/join")
      end

      def status
        JSON.parse(http_client.get(host, port, "/slave/status"))
      end

      def start_shard(shard_no)
        http_client.post(host, port, "/slave/start_shard/#{shard_no}")
      end

      def stop_shard(shard_no)
        http_client.post(host, port, "/slave/stop_shard/#{shard_no}")
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redis_ring-0.1.3 lib/redis_ring/slave_rpc.rb
redis_ring-0.1.2 lib/redis_ring/slave_rpc.rb
redis_ring-0.1.1 lib/redis_ring/slave_rpc.rb
redis_ring-0.1.0 lib/redis_ring/slave_rpc.rb