Sha256: 35186354e73475831aff31f47fd93348e44397837e9217d1e0a1085caf8747ee
Contents?: true
Size: 775 Bytes
Versions: 12
Compression:
Stored size: 775 Bytes
Contents
# encoding: utf-8 require 'eventmachine' unless defined? EventMachine require 'mysql2' unless defined? Mysql2 module Mysql2 module EM class Client < ::Mysql2::Client module Watcher def initialize(client, deferable) @client = client @deferable = deferable end def notify_readable begin @deferable.succeed(@client.async_result) rescue Exception => e @deferable.fail(e) end detach end end def query(sql, opts={}) super(sql, opts.merge(:async => true)) deferable = ::EM::DefaultDeferrable.new ::EM.watch(self.socket, Watcher, self, deferable).notify_readable = true deferable end end end end
Version data entries
12 entries across 12 versions & 1 rubygems