         "failed"
       when SUCCESS
         @finishTime - @startTime
-      when "WAITING"
+      when WAITING
         "waiting"
 
     return status

      error   : ->


class ServicePinger extends KDObject
  [NOTSTARTED, WAITING, SUCCESS, FAILED] = [1..4]

  constructor: (item, options={}) ->
    super options

    @item = item
    @identifier = options.identifier or Date.now()
    @status = NOTSTARTED


    @status = WAITING
    @startTime = Date.now()
    @setPingTimeout()
    @cb.call @item, @finish.bind(this)

  setPingTimeout: ->
    @pingTimeout = setTimeout =>
      @status = FAILED
      @emit "failed"
    , 5000

  finish: (data)->
    @status = SUCCESS
    @finishTime = Date.now()
    clearTimeout @pingTimeout
    @pingTimeout = null
    @emit "finish"

  getResponseTime: ->
    status = switch @status
