class Groonga::Client::Protocol::GQTP

Public Class Methods

new(url, options={}) click to toggle source
# File lib/groonga/client/protocol/gqtp.rb, line 30
def initialize(url, options={})
  begin
    @client = ::GQTP::Client.new(:host => url.host,
                                 :port => url.port)
  rescue ::GQTP::ConnectionError
    raise WrappedError.new($!)
  end
end

Public Instance Methods

close(&block) click to toggle source

Closes the opened connection if the current connection is still opened. You can’t send a new command after you call this method.

@overload close

Closes synchronously.

@return [Boolean] true when the opened connection is closed.
   false when there is no connection.

@overload close {}

Closes asynchronously.

@yield [] Calls the block when the opened connection is closed.
@return [#wait] The request object. If you want to wait until
   the request is processed. You can send #wait message to the
   request.
# File lib/groonga/client/protocol/gqtp.rb, line 73
def close(&block)
  sync = !block_given?
  if connected?
    return_value = @client.close(&block)
    @client = nil
    return_value
  else
    if sync
      false
    else
      EmptyRequest.new
    end
  end
end
connected?() click to toggle source

@return [Boolean] true if the current connection is opened,

false otherwise.
# File lib/groonga/client/protocol/gqtp.rb, line 52
def connected?
  not @client.nil?
end
send(command) { |response| ... } click to toggle source
# File lib/groonga/client/protocol/gqtp.rb, line 39
def send(command)
  formatted_command = command.to_command_format
  raw_response = RawResponse.new(command)
  @client.send(formatted_command) do |header, body|
    raw_response.header = header
    raw_response.body = body
    response = raw_response.to_groonga_command_compatible_response
    yield(response)
  end
end