code: func NewHeartbeat(cfg HeartbeatConfig) (*Heartbeat, error) {
  	if err := cfg.CheckAndSetDefaults(); err != nil {
  		return nil, trace.Wrap(err)
  	}
  	ctx, cancel := context.WithCancel(cfg.Context)
  	h := &Heartbeat{
  		cancelCtx:       ctx,
  		cancel:          cancel,
  		HeartbeatConfig: cfg,
  		Entry: log.WithFields(log.Fields{
  			trace.Component: teleport.Component(cfg.Component, "beat"),
  		}),
  		checkTicker: time.NewTicker(cfg.CheckPeriod),
  		announceC:   make(chan struct{}, 1),
  		sendC:       make(chan struct{}, 1),
  	}
  	h.Debugf("Starting %v heartbeat with announce period: %v, keep-alive period %v, poll period: %v", cfg.Mode, cfg.KeepAlivePeriod, cfg.AnnouncePeriod, cfg.CheckPeriod)
  	return h, nil
  }
docs: // NewHeartbeat returns a new instance of heartbeat