Class: Droonga::Client
- Inherits:
-
Object
- Object
- Droonga::Client
- Defined in:
- lib/droonga/client.rb,
lib/droonga/client/error.rb,
lib/droonga/client/version.rb,
lib/droonga/client/rate-limiter.rb,
lib/droonga/client/connection/http.rb,
lib/droonga/client/connection/error.rb,
lib/droonga/client/connection/empty-request.rb,
lib/droonga/client/connection/droonga-protocol.rb,
lib/droonga/client/connection/droonga-protocol/coolio.rb,
lib/droonga/client/connection/droonga-protocol/thread.rb
Defined Under Namespace
Modules: Connection Classes: Error, RateLimiter
Constant Summary collapse
- VERSION =
"0.1.9"
Class Method Summary collapse
-
.open(options = {}) {|client| ... } ⇒ Object
Opens a new connection and yields a Client object to use the connection.
Instance Method Summary collapse
-
#close ⇒ void
Close the connection used by the client.
-
#initialize(options = {}) ⇒ Client
constructor
Creates a new Droonga Engine client.
- #request(message, options = {}, &block) ⇒ Object
- #send(message, options = {}, &block) ⇒ Object
- #subscribe(message, options = {}, &block) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Creates a new Droonga Engine client.
62 63 64 |
# File 'lib/droonga/client.rb', line 62 def initialize(={}) @connection = create_connection() end |
Class Method Details
.open(options = {}) {|client| ... } ⇒ Object
Opens a new connection and yields a Droonga::Client object to use the connection. The client is closed after the given block is finished.
37 38 39 40 41 42 43 44 |
# File 'lib/droonga/client.rb', line 37 def open(={}) client = new() begin yield(client) ensure client.close end end |
Instance Method Details
#close ⇒ void
This method returns an undefined value.
Close the connection used by the client. You can't send any request anymore.
93 94 95 |
# File 'lib/droonga/client.rb', line 93 def close @connection.close end |
#request(message, options = {}, &block) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/droonga/client.rb', line 75 def request(, ={}, &block) if ["id"].nil? = .merge("id" => generate_id) end @connection.request(, , &block) end |
#send(message, options = {}, &block) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/droonga/client.rb', line 66 def send(, ={}, &block) if ["id"].nil? or ["date"].nil? id = ["id"] || generate_id date = ["date"] || Time.now = .merge("id" => id, "date" => date) end @connection.send(, , &block) end |
#subscribe(message, options = {}, &block) ⇒ Object
82 83 84 85 86 87 |
# File 'lib/droonga/client.rb', line 82 def subscribe(, ={}, &block) if ["id"].nil? = .merge("id" => generate_id) end @connection.subscribe(, , &block) end |