Class: Groonga::Client::Protocol::GQTP
- Inherits:
-
Object
- Object
- Groonga::Client::Protocol::GQTP
- Defined in:
- lib/groonga/client/protocol/gqtp.rb
Defined Under Namespace
Classes: RawResponse
Instance Method Summary collapse
-
#close(&block) ⇒ Object
Closes the opened connection if the current connection is still opened.
-
#connected? ⇒ Boolean
True if the current connection is opened, false otherwise.
-
#initialize(url, options = {}) ⇒ GQTP
constructor
A new instance of GQTP.
- #send(command) ⇒ Object
Constructor Details
#initialize(url, options = {}) ⇒ GQTP
Returns a new instance of GQTP.
30 31 32 33 34 35 36 37 |
# File 'lib/groonga/client/protocol/gqtp.rb', line 30 def initialize(url, ={}) begin @client = ::GQTP::Client.new(:host => url.host, :port => url.port) rescue ::GQTP::ConnectionError raise WrappedError.new($!) end end |
Instance Method Details
#close ⇒ Boolean #close({}) { ... } ⇒ #wait
Closes the opened connection if the current connection is still opened. You can't send a new command after you call this method.
73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# 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? ⇒ Boolean
Returns true if the current connection is opened, false otherwise.
52 53 54 |
# File 'lib/groonga/client/protocol/gqtp.rb', line 52 def connected? not @client.nil? end |
#send(command) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# 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 |