func main() {
	runtime.GOMAXPROCS(runtime.NumCPU())

	configFilePath := flag.String("config", "config/opentsdb-firehose-nozzle.json", "Location of the nozzle config json file")
	flag.Parse()

	config, err := nozzleconfig.Parse(*configFilePath)
	if err != nil {
		log.Fatalf("Error parsing config: %s", err.Error())
	}

	tokenFetcher := &uaatokenfetcher.UAATokenFetcher{
		UaaUrl:                config.UAAURL,
		Username:              config.Username,
		Password:              config.Password,
		InsecureSSLSkipVerify: config.InsecureSSLSkipVerify,
	}

	threadDumpChan := registerGoRoutineDumpSignalChannel()
	defer close(threadDumpChan)
	go dumpGoRoutine(threadDumpChan)

	opentsdbNozzle := opentsdbfirehosenozzle.NewOpenTSDBFirehoseNozzle(config, tokenFetcher)
	opentsdbNozzle.Start()
}
import (
	"os"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
	"github.com/pivotal-cf-experimental/opentsdb-firehose-nozzle/nozzleconfig"
)

var _ = Describe("NozzleConfig", func() {
	BeforeEach(func() {
		os.Clearenv()
	})

	It("successfully parses a valid config", func() {
		conf, err := nozzleconfig.Parse("../config/opentsdb-firehose-nozzle.json")
		Expect(err).ToNot(HaveOccurred())
		Expect(conf.UAAURL).To(Equal("https://uaa.pilsner.pcf-metrics.com"))
		Expect(conf.Username).To(Equal("apps_metrics_processing"))
		Expect(conf.Password).To(Equal("secret"))
		Expect(conf.TrafficControllerURL).To(Equal("wss://doppler.pilsner.pcf-metrics.com:4443"))
		Expect(conf.FirehoseSubscriptionID).To(Equal("opentsdb-nozzle"))
		Expect(conf.OpenTSDBURL).To(Equal("http://localhost"))
		Expect(conf.FlushDurationSeconds).To(BeEquivalentTo(15))
		Expect(conf.InsecureSSLSkipVerify).To(Equal(true))
		Expect(conf.MetricPrefix).To(Equal("opentsdbclient"))
		Expect(conf.Deployment).To(Equal("deployment-name"))
		Expect(conf.DisableAccessControl).To(Equal(false))
		Expect(conf.UseTelnetAPI).To(BeEquivalentTo(true))
		Expect(conf.Job).To(Equal("opentsdb-firehose-nozzle"))
		Expect(conf.Index).To(BeEquivalentTo("SOME-GUID"))