Class: Groonga::Client::Protocol::HTTP::Coolio

Inherits:
Object
  • Object
show all
Defined in:
lib/groonga/client/protocol/http/coolio.rb

Defined Under Namespace

Classes: GroongaHTTPClient, Request

Instance Method Summary collapse

Constructor Details

#initialize(host, port, options) ⇒ Coolio

Returns a new instance of Coolio.



66
67
68
69
70
71
# File 'lib/groonga/client/protocol/http/coolio.rb', line 66

def initialize(host, port, options)
  @host = host
  @port = port
  @options = options
  @loop = @options[:loop] || ::Coolio::Loop.default
end

Instance Method Details

#close(&block) ⇒ Object



99
100
101
102
103
104
105
106
107
# File 'lib/groonga/client/protocol/http/coolio.rb', line 99

def close(&block)
  sync = !block_given?
  if sync
    false
  else
    yield
    EmptyRequest.new
  end
end

#connected?Boolean

Returns:

  • (Boolean)


95
96
97
# File 'lib/groonga/client/protocol/http/coolio.rb', line 95

def connected?
  false
end

#send(command, &block) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/groonga/client/protocol/http/coolio.rb', line 73

def send(command, &block)
  client = GroongaHTTPClient.connect(@host, @port, block)
  client.attach(@loop)
  if command.name == "load"
    raw_values = command[:values]
    command[:values] = nil
    path = 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
    client.request("GET", command.to_uri_format)
  end
  Request.new(client, @loop)
end