Class: Groonga::Client::Protocol::HTTP::Coolio
- Inherits:
-
Object
- Object
- Groonga::Client::Protocol::HTTP::Coolio
- Defined in:
- lib/groonga/client/protocol/http/coolio.rb
Defined Under Namespace
Classes: GroongaHTTPClient, Request
Instance Method Summary collapse
- #close(&block) ⇒ Object
- #connected? ⇒ Boolean
-
#initialize(host, port, options) ⇒ Coolio
constructor
A new instance of Coolio.
- #send(command, &block) ⇒ Object
Constructor Details
#initialize(host, port, options) ⇒ Coolio
Returns a new instance of Coolio.
69 70 71 72 73 74 |
# File 'lib/groonga/client/protocol/http/coolio.rb', line 69 def initialize(host, port, ) @host = host @port = port @options = @loop = @options[:loop] || ::Coolio::Loop.default end |
Instance Method Details
#close(&block) ⇒ Object
104 105 106 107 108 109 110 111 112 |
# File 'lib/groonga/client/protocol/http/coolio.rb', line 104 def close(&block) sync = !block_given? if sync false else yield EmptyRequest.new end end |
#connected? ⇒ Boolean
100 101 102 |
# File 'lib/groonga/client/protocol/http/coolio.rb', line 100 def connected? false end |
#send(command, &block) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/groonga/client/protocol/http/coolio.rb', line 76 def send(command, &block) client = GroongaHTTPClient.connect(@host, @port, block) client.attach(@loop) url = URI("http://#{@host}:#{@port}") if command.is_a?(Groonga::Command::Load) raw_values = command[:values] command[:values] = nil path = resolve_path(url, command.to_uri_format) command[:values] = raw_values = { :head => { "content-type" => "application/json", "user-agent" => @options[:user_agent], }, :body => raw_values, } client.request("POST", path, ) else path = resolve_path(url, command.to_uri_format) client.request("GET", path) end Request.new(client, @loop) end |