Sha256: c84a6b0f88749dd6ecc38ebe79b53c04eca1e184a7d1bf52e487a456027e98b3

Contents?: true

Size: 964 Bytes

Versions: 1

Compression:

Stored size: 964 Bytes

Contents

safe_require 'sequel', 'gem install sequel'
require 'sequel/adapters/postgres'

##
# Midori Extension of sequel postgres through meta programming
class Sequel::Postgres::Adapter
  # Call a sql request asynchronously
  # @param [String] sql sql request
  # @param [Array] args args to send
  # @return [Array] sql query result
  def execute_query(sql, args)
      @db.log_connection_yield(sql, self, args) do
        socket_object = IO.for_fd(socket)
        await(Promise.new do |resolve|
          EventLoop.register(socket_object, :w) do
            unless is_busy
              EventLoop.unregister(socket_object)
              send_query(sql)
              resolve.call
            end
          end
        end)

        await(Promise.new do |resolve|
          consume_input
          EventLoop.register(socket_object, :r) do
            EventLoop.unregister(socket_object)
            resolve.call(get_result)
          end
        end)
      end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
em-midori-0.1.11 lib/midori/extension/sequel/postgres.rb