Sha256: 3b2008a4418d6a19a95d470e40c2d3b4ab42b119f4b002a37fb388acc4a0b85c

Contents?: true

Size: 813 Bytes

Versions: 10

Compression:

Stored size: 813 Bytes

Contents

begin
  require "em-jack"
rescue LoadError => error
  raise "Missing EM-Synchrony dependency: gem install em-jack"
end

# WANT: namespaced under EventMachine.. would be nice :-)
# NOTE: no need for "pooling" since Beanstalk supports pipelining
module EMJack
  class Connection

    alias :ause :use
    def use(tube, &blk)
      return if @used_tube == tube

      f = Fiber.current

      # WANT: per command errbacks, would be nice, instead of one global
      # errback  = Proc.new {|r| f.resume(r) }

      on_error {|r| f.resume(r)}

      @used_tube = tube
      @conn.send(:use, tube)

      # WANT: Add conditional on add_deferrable to either accept two procs, or a single block
      #       .. two procs = callback, errback
      add_deferrable { |r| f.resume(r) }

      Fiber.yield
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
em-synchrony-1.0.6 lib/em-synchrony/em-jack.rb
em-synchrony-1.0.5 lib/em-synchrony/em-jack.rb
em-synchrony-1.0.4 lib/em-synchrony/em-jack.rb
em-synchrony-1.0.3 lib/em-synchrony/em-jack.rb
em-synchrony-1.0.2 lib/em-synchrony/em-jack.rb
em-synchrony-1.0.1 lib/em-synchrony/em-jack.rb
em-synchrony-1.0.0 lib/em-synchrony/em-jack.rb
em-synchrony-0.3.0.beta.1 lib/em-synchrony/em-jack.rb
em-synchrony-0.2.0 lib/em-synchrony/em-jack.rb
em-synchrony-0.1.5 lib/em-synchrony/em-jack.rb