Class: Combi::EventedWaiter
- Inherits:
-
Object
- Object
- Combi::EventedWaiter
- Includes:
- EM::Deferrable
- Defined in:
- lib/combi/response_store.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(key, response_store, timeout) ⇒ EventedWaiter
constructor
A new instance of EventedWaiter.
Constructor Details
#initialize(key, response_store, timeout) ⇒ EventedWaiter
Returns a new instance of EventedWaiter.
49 50 51 |
# File 'lib/combi/response_store.rb', line 49 def initialize(key, response_store, timeout) self.timeout(timeout, 'error' => 'Timeout::Error') end |
Class Method Details
.log(message) ⇒ Object
34 35 36 37 |
# File 'lib/combi/response_store.rb', line 34 def self.log() return unless @debug_mode ||= ENV['DEBUG'] == 'true' puts "#{Time.now.to_f} #{self.name} #{}" end |
.wait_for(key, response_store, timeout) ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/combi/response_store.rb', line 39 def self.wait_for(key, response_store, timeout) t1 = Time.now log "started waiting for #{key}" waiter = new(key, response_store, timeout) response_store.add_waiter(key, waiter) waiter.callback {|r| log "success waiting for #{key}: #{Time.now.to_f - t1.to_f}s" } waiter.errback {|r| log "failed waiting for #{key}: #{Time.now.to_f - t1.to_f}s, #{r.inspect[0..500]}" } waiter end |