Class: Groonga::Client::Protocol::HTTP::Synchronous
- Inherits:
-
Object
- Object
- Groonga::Client::Protocol::HTTP::Synchronous
- Includes:
- PathResolvable
- Defined in:
- lib/groonga/client/protocol/http/synchronous.rb
Direct Known Subclasses
Defined Under Namespace
Classes: HTTPClient
Constant Summary collapse
- DEBUG =
(ENV["GROONGA_CLIENT_HTTP_DEBUG"] == "yes")
Instance Method Summary collapse
-
#close(&block) ⇒ Object
Does nothing because the current implementation doesn't support keep-alive.
-
#connected? ⇒ false
Always returns false because the current implementation doesn't support keep-alive.
-
#initialize(url, options = {}) ⇒ Synchronous
constructor
A new instance of Synchronous.
- #send(command) ⇒ Object
Constructor Details
#initialize(url, options = {}) ⇒ Synchronous
Returns a new instance of Synchronous.
53 54 55 56 |
# File 'lib/groonga/client/protocol/http/synchronous.rb', line 53 def initialize(url, ={}) @url = url @options = end |
Instance Method Details
#close ⇒ false #close({}) { ... } ⇒ #wait
Does nothing because the current implementation doesn't support keep-alive. If the implementation supports keep-alive, it close the opend connection.
111 112 113 114 115 116 117 118 119 |
# File 'lib/groonga/client/protocol/http/synchronous.rb', line 111 def close(&block) sync = !block_given? if sync false else yield EmptyRequest.new end end |
#connected? ⇒ false
Returns Always returns false because the current implementation doesn't support keep-alive.
90 91 92 |
# File 'lib/groonga/client/protocol/http/synchronous.rb', line 90 def connected? false end |
#send(command) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/groonga/client/protocol/http/synchronous.rb', line 59 def send(command) begin http = HTTPClient.new(@url.host, @url.port) http.set_debug_output($stderr) if DEBUG .each do |key, value| http.__send__("#{key}=", value) end http.start do http.read_timeout = read_timeout response = send_request(http, command) case response when Net::HTTPSuccess, Net::HTTPBadRequest yield(response.body) else if response.body.start_with?("[[") yield(response.body) else = "#{response.code} #{response.}: #{response.body}" raise Error.new() end end end rescue SystemCallError, Timeout::Error raise WrappedError.new($!) end EmptyRequest.new end |