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

default_query_options, #info, #initialize, #parse_connect_attrs, #parse_flags_array, #parse_ssl_mode, #query_info

Constructor Details

This class inherits a constructor from Mysql2::Client

Instance Method Details

#close(*args) ⇒ Object



34
35
36
37
38
# File 'lib/mysql2/em.rb', line 34

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

  super(*args)
end

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



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

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