code: func check(hrt heart.Heart, ttl time.Duration) (idx uint64, err error) {
  	// time out after a third of the machine presence TTL, attempting
  	// the heartbeat up to four times
  	timeout := ttl / 3
  	interval := timeout / 4
  
  	tchan := time.After(timeout)
  	next := time.After(0)
  	for idx == 0 {
  		select {
  		case <-tchan:
  			err = errors.New("Monitor timed out before successful heartbeat")
  			return
  		case <-next:
  			idx, err = hrt.Beat(ttl)
  			if err != nil {
  				log.Debugf("Monitor heartbeat function returned err, retrying in %v: %v", interval, err)
  			}
  
  			next = time.After(interval)
  		}
  	}
  
  	return
  }
docs: // check attempts to beat a Heart several times within a timeout, returning the
  // log index at which the beat succeeded or an error