Sha256: d418aa79aeb9af3dd958ece868337d3af5a4b351e95ea21a35d1ba12b0d532ed

Contents?: true

Size: 679 Bytes

Versions: 32

Compression:

Stored size: 679 Bytes

Contents

# encoding: utf-8

require 'mysql2/em'
require 'fiber'

module Mysql2
  module EM
    module Fiber
      class Client < ::Mysql2::EM::Client
        def query(sql, opts={})
          if ::EM.reactor_running?
            deferable = super(sql, opts)

            fiber = ::Fiber.current
            deferable.callback do |result|
              fiber.resume(result)
            end
            deferable.errback do |err|
              fiber.resume(err)
            end
            ::Fiber.yield.tap do |result|
              raise result if result.is_a?(::Exception)
            end
          else
            super(sql, opts)
          end
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 3 rubygems

Version Path
mysql2-0.3.5 lib/mysql2/em_fiber.rb
mysql2-0.2.10 lib/mysql2/em_fiber.rb
mysql2-0.3.4 lib/mysql2/em_fiber.rb
mysql2-0.2.9 lib/mysql2/em_fiber.rb
mysql2-0.3.3 lib/mysql2/em_fiber.rb
mysql2-0.2.8 lib/mysql2/em_fiber.rb
rdp-mysql2-0.2.7.1 lib/mysql2/em_fiber.rb
mysql2-0.3.2 lib/mysql2/em_fiber.rb
mysql2-0.3.1 lib/mysql2/em_fiber.rb
mysql2-0.3.0 lib/mysql2/em_fiber.rb
mysql2-0.2.7 lib/mysql2/em_fiber.rb
mysql2_bigint-0.2.6.1 lib/mysql2/em_fiber.rb