code: func (d *Discovery) Run(ctx context.Context, ch chan<- []*targetgroup.Group) {
  	// Get an initial set right away.
  	tgs, err := d.refresh(ctx)
  	if err != nil {
  		level.Error(d.logger).Log("msg", "Unable to refresh target groups", "err", err.Error())
  	} else {
  		select {
  		case ch <- tgs:
  		case <-ctx.Done():
  			return
  		}
  	}
  
  	ticker := time.NewTicker(d.interval)
  	defer ticker.Stop()
  
  	for {
  		select {
  		case <-ticker.C:
  			tgs, err := d.refresh(ctx)
  			if err != nil {
  				level.Error(d.logger).Log("msg", "Unable to refresh target groups", "err", err.Error())
  				continue
  			}
  
  			select {
  			case ch <- tgs:
  			case <-ctx.Done():
  				return
  			}
  		case <-ctx.Done():
  			return
  		}
  	}
  }
docs: // Run implements the Discoverer interface.