Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Ruby
Branch: master

This branch is 1 commit ahead of jzimmek:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
Gemfile
LICENSE.txt
README.md
Rakefile
em-postgresql-sequel.gemspec

README.md

EM Postgresql Sequel

Installation

  • gem install pg
  • gem install eventmachine
  • gem install sequel
  • gem install em-postgresql-sequel

Examples

Run 3 fiber queries concurrently, utilizing 3 connections

['logger', 'pg', 'sequel', 'eventmachine', 'em-postgresql-sequel', 'fiber'].each do |lib| 
  require lib
end

EM::run do
  Fiber.new do
    DB = Sequel.connect 'postgres://user:pass@localhost:5432/db', :logger => Logger.new(STDOUT), :max_connections => 3, :pool_class => EM::Sequel::FiberedConnectionPool

    (1..10).each do |num|
      Fiber.new do
        res = DB["select 'f#{num}' as fiber, pg_sleep(3)"].all
        puts "f#{num} done, res: #{res.inspect}"
      end.resume
    end
  end.resume
end

Run 1 fiber query at a time, utilizing 1 connection

['logger', 'pg', 'sequel', 'eventmachine', 'em-postgresql-sequel', 'fiber'].each do |lib| 
  require lib
end

EM::run do
  Fiber.new do
    DB = Sequel.connect 'postgres://user:pass@localhost:5432/db', :logger => Logger.new(STDOUT), :max_connections => 1, :pool_class => EM::Sequel::FiberedConnectionPool

    (1..10).each do |num|
      Fiber.new do
        res = DB["select 'f#{num}' as fiber, pg_sleep(3)"].all
        puts "f#{num} done, res: #{res.inspect}"
      end.resume
    end
  end.resume
end

Known Issues

  • disconnected connection

Todos

  • add some test cases

Credits

Something went wrong with that request. Please try again.