class Droonga::Client::Connection::DroongaProtocol::Coolio::Sender
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/droonga/client/connection/droonga-protocol/coolio.rb, line 72 def initialize(*args) super @connected = false @failed_to_connect = false @buffer = [] end
Public Instance Methods
close()
click to toggle source
Calls superclass method
# File lib/droonga/client/connection/droonga-protocol/coolio.rb, line 79 def close return if @failed_to_connect super end
on_connect()
click to toggle source
# File lib/droonga/client/connection/droonga-protocol/coolio.rb, line 97 def on_connect @connected = true @buffer.each do |packed_message,| write(packed_message) end @buffer.clear end
on_connect_failed()
click to toggle source
# File lib/droonga/client/connection/droonga-protocol/coolio.rb, line 105 def on_connect_failed @failed_to_connect = true @buffer.each do |packed_message, on_error| _, _, message = MessagePack.unpack(packed_message) on_error.call(message) end @buffer.clear end
send(tag, data, &on_error)
click to toggle source
# File lib/droonga/client/connection/droonga-protocol/coolio.rb, line 84 def send(tag, data, &on_error) if @failed_to_connect on_error.call(data) end fluent_message = [tag, Time.now.to_i, data] packed_fluent_message = MessagePackPacker.pack(fluent_message) if @connected write(packed_fluent_message) else @buffer << [packed_fluent_message, on_error] end end