def send_retryable_request(type, conn, payload = nil, opts = {})
      req = RetryableRequest.new(type, payload, opts)

      callback = Proc.new do |content|
        result = OperationResult.success(content)
        reply = @serializer.dump(result) rescue '\"Failed to serialize response\"'
        CommandIO.instance.reply(conn, reply)
      end

      errback = Proc.new do |content|
        result = OperationResult.error(content)
        reply = @serializer.dump(result) rescue '\"Failed to serialize response\"'
        CommandIO.instance.reply(conn, reply)
      end

      req.callback(&callback)
      req.errback(&errback)
      req.run
    end
def send_retryable_request(type, conn, payload = nil, opts = {})
      req = RetryableRequest.new(type, payload, opts)

      callback = Proc.new do |content|
        result = OperationResult.success(content)
        reply = @serializer.dump(result) rescue '\"Failed to serialize response\"'
        CommandIO.instance.reply(conn, reply)
      end

      errback = Proc.new do |content|
        result = OperationResult.error(content)
        reply = @serializer.dump(result) rescue '\"Failed to serialize response\"'
        CommandIO.instance.reply(conn, reply)
      end

      req.callback(&callback)
      req.errback(&errback)
      req.run
    end
Helper method to send a retryable request to a single target with a response expected,
 retrying at the application layer until the request succeeds or the timeout elapses;
 default timeout is 'forever'.

 See RetryableRequest for details