Class: KingKong::Ping::Deferrable

Inherits:
KingKong::Ping show all
Includes:
EventMachine::Deferrable
Defined in:
lib/kingkong/ping.rb

Overview

Add evented functionality to a ping so that it times out, etc.

Constant Summary

Constants inherited from KingKong::Ping

NotStartedError

Instance Attribute Summary

Attributes inherited from KingKong::Ping

#end_time, #start_time, #ttl

Instance Method Summary collapse

Methods inherited from KingKong::Ping

#active?, #completed?, default_ttl, #id, #initialize, #latency, #not_started?, sequencer, #status, #timed_out?, #to_hash, #to_s

Constructor Details

This class inherits a constructor from KingKong::Ping

Instance Method Details

#startObject

Setup a ttl for the ping so that it will timeout after ttl seconds



132
133
134
135
# File 'lib/kingkong/ping.rb', line 132

def start
  timeout(ttl) # Setup an em TTL on this thing so it fails if the thing isn't called
  super
end

#stop(&block) ⇒ Object

Succeed a block passed into the ping and mark the ping as suceeded



138
139
140
141
142
# File 'lib/kingkong/ping.rb', line 138

def stop(&block)
  callback(&block) if block_given?
  super
  succeed self
end