Class: Mysql2::EM::Client

Inherits:
Client
  • Object
show all
Defined in:
lib/mysql2/em.rb

Defined Under Namespace

Modules: Watcher

Constant Summary

Constants inherited from Client

Client::CHARSET_MAP, Client::MYSQL_CHARSET_MAP

Instance Attribute Summary

Attributes inherited from Client

#query_options

Instance Method Summary collapse

Methods inherited from Client

#affected_rows, #async_result, #close, default_query_options, #encoding, encoding_from_charset, encoding_from_charset_code, #escape, escape, #info, #initialize, #last_id, #ping, #server_info, #socket, #thread_id

Constructor Details

This class inherits a constructor from Mysql2::Client

Instance Method Details

#query(sql, opts = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
# File 'lib/mysql2/em.rb', line 25

def query(sql, opts={})
  if ::EM.reactor_running?
    super(sql, opts.merge(:async => true))
    deferable = ::EM::DefaultDeferrable.new
    ::EM.watch(self.socket, Watcher, self, deferable).notify_readable = true
    deferable
  else
    super(sql, opts)
  end
end