Class: Mysql2::EM::Client

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

Defined Under Namespace

Modules: Watcher

Instance Attribute Summary

Attributes inherited from Client

#query_options, #read_timeout

Instance Method Summary collapse

Methods inherited from Client

#abandon_results!, #affected_rows, #async_result, #automatic_close=, #automatic_close?, default_query_options, #encoding, escape, #escape, #info, info, #initialize, #last_id, #more_results?, #next_result, #parse_flags_array, #ping, #prepare, #query_info, #query_info_string, #reconnect=, #select_db, #server_info, #socket, #ssl_cipher, #store_result, #thread_id, #warning_count

Constructor Details

This class inherits a constructor from Mysql2::Client

Instance Method Details

#close(*args) ⇒ Object



36
37
38
39
40
# File 'lib/mysql2/em.rb', line 36

def close(*args)
  @watch.detach if @watch && @watch.watching?

  super(*args)
end

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



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mysql2/em.rb', line 42

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