code: func NewService(t *testing.T, etcdClientPort, etcdPeerPort, httpPort int) *Service {
  	dataDir, err := ioutil.TempDir(os.TempDir(), "test-data")
  	if err != nil {
  		t.Fatal(err)
  	}
  
  	cfg := embed.NewConfig()
  	cfg.ClusterState = embed.ClusterStateFlagNew
  	cfg.Name = "test-etcd"
  	cfg.Dir = dataDir
  	curl := url.URL{Scheme: "http", Host: fmt.Sprintf("localhost:%d", etcdClientPort)}
  	cfg.ACUrls, cfg.LCUrls = []url.URL{curl}, []url.URL{curl}
  	purl := url.URL{Scheme: "http", Host: fmt.Sprintf("localhost:%d", etcdPeerPort)}
  	cfg.APUrls, cfg.LPUrls = []url.URL{purl}, []url.URL{purl}
  	cfg.InitialCluster = fmt.Sprintf("%s=%s", cfg.Name, cfg.APUrls[0].String())
  	cfg.SnapCount = 1000 // single-node, keep minimum snapshot
  
  	// TODO: enable this with etcd v3.3+
  	// cfg.AutoCompactionMode = compactor.ModePeriodic
  	// cfg.AutoCompactionRetention = 1
  
  	ctx, cancel := context.WithCancel(context.Background())
  	return &Service{
  		rootCtx:    ctx,
  		rootCancel: cancel,
  
  		cfg:      cfg,
  		dataDir:  dataDir,
  		etcdCURL: curl,
  
  		httpEp: fmt.Sprintf("http://localhost:%d", httpPort),
  		httpServer: &http.Server{
  			Addr:    fmt.Sprintf("localhost:%d", httpPort),
  			Handler: discoveryhttp.RegisterHandlers(ctx, cfg.LCUrls[0].String(), testDiscoveryHost),
  		},
  		httpErrc: make(chan error),
  	}
  }
docs: // NewService creates a new service.