Class: Swift::Adapter::EMHandler

Inherits:
EM::Connection
  • Object
show all
Defined in:
lib/swift/eventmachine.rb

Instance Method Summary collapse

Constructor Details

#initialize(adapter, record, defer) ⇒ EMHandler

Returns a new instance of EMHandler.



12
13
14
15
16
17
# File 'lib/swift/eventmachine.rb', line 12

def initialize adapter, record, defer
  @started = Time.now
  @adapter = adapter
  @record  = record
  @defer   = defer
end

Instance Method Details

#notify_readableObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/swift/eventmachine.rb', line 19

def notify_readable
  detach
  start, command, bind = @adapter.pending.shift
  @adapter.log_command(start, command, bind) if @adapter.trace?

  begin
    @defer.succeed(@record ? Result.new(@record, @adapter.result) : @adapter.result)
  rescue Exception => e
    @defer.fail(e)
  end
end