func NewNsqExecutor(namespace, nsqdURL, tlsCACert, tlsCert, tlsKey string) (*NsqExecutor, error) {
	sum := prometheus.NewSummaryVec(prometheus.SummaryOpts{
		Namespace: namespace,
		Subsystem: "exporter",
		Name:      "scrape_duration_seconds",
		Help:      "Duration of a scrape job of the NSQ exporter",
	}, []string{"result"})
	prometheus.MustRegister(sum)
	transport := &http.Transport{}
	if tlsCert != "" && tlsKey != "" {
		cert, err := tls.LoadX509KeyPair(tlsCert, tlsKey)
		if err != nil {
			return nil, err
		}
		caCertPool := x509.NewCertPool()
		if tlsCACert != "" {
			caCert, err := ioutil.ReadFile(tlsCACert)
			if err != nil {
				return nil, err
			}
			caCertPool.AppendCertsFromPEM(caCert)
		}
		tlsConfig := &tls.Config{
			Certificates: []tls.Certificate{cert},
			RootCAs:      caCertPool,
		}
		tlsConfig.BuildNameToCertificate()
		transport.TLSClientConfig = tlsConfig
	}
	return &NsqExecutor{
		nsqdURL: nsqdURL,
		summary: sum,
		client:  &http.Client{Transport: transport},
	}, nil
}
NewNsqExecutor creates a new executor for collecting NSQ metrics.
package collector
import (
	"crypto/tls"
	"crypto/x509"
	"io/ioutil"
	"net/http"
	"sync"
	"time"
	"github.com/prometheus/client_golang/prometheus"
)
type NsqExecutor struct {
	nsqdURL string
	collectors []StatsCollector
	summary    *prometheus.SummaryVec
	client     *http.Client
	mutex      sync.RWMutex
}