code: func (m *AgentMDNS) run() {
  	hosts := make(chan *mdns.ServiceEntry, 32)
  	poll := time.After(0)
  	var quiet <-chan time.Time
  	var join []string
  
  	for {
  		select {
  		case h := <-hosts:
  			// Format the host address
  			addr := net.TCPAddr{IP: h.Addr, Port: h.Port}
  			addrS := addr.String()
  
  			// Skip if we've handled this host already
  			if _, ok := m.seen[addrS]; ok {
  				continue
  			}
  
  			// Queue for handling
  			join = append(join, addrS)
  			quiet = time.After(mdnsQuietInterval)
  
  		case <-quiet:
  			// Attempt the join
  			n, err := m.agent.Join(join, m.replay)
  			if err != nil {
  				m.logger.Printf("[ERR] agent.mdns: Failed to join: %v", err)
  			}
  			if n > 0 {
  				m.logger.Printf("[INFO] agent.mdns: Joined %d hosts", n)
  			}
  
  			// Mark all as seen
  			for _, n := range join {
  				m.seen[n] = struct{}{}
  			}
  			join = nil
  
  		case <-poll:
  			poll = time.After(mdnsPollInterval)
  			go m.poll(hosts)
  		}
  	}
  }
docs: // run is a long running goroutine that scans for new hosts periodically