code: func (d *DNSServer) serviceLookup(cfg *dnsConfig, network, datacenter, service, tag string, connect bool, req, resp *dns.Msg, maxRecursionLevel int) {
  	out, err := d.lookupServiceNodes(cfg, datacenter, service, tag, connect, maxRecursionLevel)
  	if err != nil {
  		d.logger.Printf("[ERR] dns: rpc error: %v", err)
  		resp.SetRcode(req, dns.RcodeServerFailure)
  		return
  	}
  
  	// If we have no nodes, return not found!
  	if len(out.Nodes) == 0 {
  		d.addSOA(cfg, resp)
  		resp.SetRcode(req, dns.RcodeNameError)
  		return
  	}
  
  	// Perform a random shuffle
  	out.Nodes.Shuffle()
  
  	// Determine the TTL
  	ttl, _ := cfg.GetTTLForService(service)
  
  	// Add various responses depending on the request
  	qType := req.Question[0].Qtype
  	if qType == dns.TypeSRV {
  		d.serviceSRVRecords(cfg, datacenter, out.Nodes, req, resp, ttl, maxRecursionLevel)
  	} else {
  		d.serviceNodeRecords(cfg, datacenter, out.Nodes, req, resp, ttl, maxRecursionLevel)
  	}
  
  	d.trimDNSResponse(cfg, network, req, resp)
  
  	// If the answer is empty and the response isn't truncated, return not found
  	if len(resp.Answer) == 0 && !resp.Truncated {
  		d.addSOA(cfg, resp)
  		return
  	}
  }
docs: // serviceLookup is used to handle a service query