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, default_query_options, #encoding, escape, #escape, info, #info, #initialize, #last_id, #more_results?, #next_result, #ping, #prepare, #query_info, #query_info_string, #reconnect=, #select_db, #server_info, #socket, #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
41
# File 'lib/mysql2/em.rb', line 36

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

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



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

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