class Groonga::Client::Protocol::HTTP::Coolio

Public Class Methods

new(host, port, options) click to toggle source
# File lib/groonga/client/protocol/http/coolio.rb, line 69
def initialize(host, port, options)
  @host = host
  @port = port
  @options = options
  @loop = @options[:loop] || ::Coolio::Loop.default
end

Public Instance Methods

close() { || ... } click to toggle source
# 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?() click to toggle source
# File lib/groonga/client/protocol/http/coolio.rb, line 100
def connected?
  false
end
send(command, &block) click to toggle source
# 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
    options = {
      :head => {
        "content-type" => "application/json",
        "user-agent"   => @options[:user_agent],
      },
      :body => raw_values,
    }
    client.request("POST", path, options)
  else
    path = resolve_path(url, command.to_uri_format)
    client.request("GET", path)
  end
  Request.new(client, @loop)
end