['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
['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