Sha256: e5e624ca4c00924bc6aeb571fbc3e69a97d76551bd28e9b2d990b38cb882a437
Contents?: true
Size: 816 Bytes
Versions: 42
Compression:
Stored size: 816 Bytes
Contents
# encoding: utf-8 require 'eventmachine' require 'mysql2' module Mysql2 module EM class Client < ::Mysql2::Client module Watcher def initialize(client, deferable) @client = client @deferable = deferable end def notify_readable detach begin @deferable.succeed(@client.async_result) rescue Exception => e @deferable.fail(e) end end end 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 end end end
Version data entries
42 entries across 42 versions & 6 rubygems