當前位置: 首頁>>代碼示例>>Golang>>正文


Golang config.ReadConfig函數代碼示例

本文整理匯總了Golang中fullerite/config.ReadConfig函數的典型用法代碼示例。如果您正苦於以下問題:Golang ReadConfig函數的具體用法?Golang ReadConfig怎麽用?Golang ReadConfig使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ReadConfig函數的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: start

func start(ctx *cli.Context) {
	if ctx.Bool("profile") {
		pcfg := profile.Config{
			CPUProfile:   true,
			MemProfile:   true,
			BlockProfile: true,
			ProfilePath:  ".",
		}
		p := profile.Start(&pcfg)
		defer p.Stop()
	}
	initLogrus(ctx)
	log.Info("Starting fullerite...")

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}
	collectors := startCollectors(c)
	handlers := startHandlers(c)

	internalServer := internalserver.New(c, &handlers)
	go internalServer.Run()

	metrics := make(chan metric.Metric)
	readFromCollectors(collectors, metrics)

	hook := NewLogErrorHook(metrics)
	log.Logger.Hooks.Add(hook)

	relayMetricsToHandlers(handlers, metrics)
}
開發者ID:carriercomm,項目名稱:fullerite,代碼行數:32,代碼來源:main.go

示例2: start

func start(ctx *cli.Context) {
	if ctx.Bool("profile") {
		defer profile.Start(profile.CPUProfile).Stop()
		defer profile.Start(profile.MemProfile).Stop()
		defer profile.Start(profile.BlockProfile).Stop()
		defer profile.Start(profile.ProfilePath("."))
	}
	quit := make(chan bool)
	initLogrus(ctx)
	log.Info("Starting fullerite...")

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}
	handlers := createHandlers(c)
	hook := NewLogErrorHook(handlers)
	log.Logger.Hooks.Add(hook)

	startHandlers(handlers)
	collectors := startCollectors(c)

	collectorStatChan := make(chan metric.CollectorEmission)

	internalServer := internalserver.New(c,
		handlerStatFunc(handlers),
		readCollectorStat(collectorStatChan))

	go internalServer.Run()

	readFromCollectors(collectors, handlers, collectorStatChan)

	<-quit
}
開發者ID:Yelp,項目名稱:fullerite,代碼行數:34,代碼來源:main.go

示例3: start

func start(ctx *cli.Context) {
	if ctx.Bool("profile") {
		pcfg := profile.Config{
			CPUProfile:   true,
			MemProfile:   true,
			BlockProfile: true,
			ProfilePath:  ".",
		}
		p := profile.Start(&pcfg)
		defer p.Stop()
	}
	initLogrus(ctx)
	log.Info("Starting fullerite...")

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}
	collectors := startCollectors(c)
	handlers := startHandlers(c)
	metrics := make(chan metric.Metric)
	readFromCollectors(collectors, metrics)
	for metric := range metrics {
		// Writing to handlers' channels. Sending metrics is
		// handled asynchronously in handlers' Run functions.
		writeToHandlers(handlers, metric)
	}
}
開發者ID:jaxxstorm,項目名稱:fullerite,代碼行數:28,代碼來源:main.go

示例4: TestStartCollectorsMixedConfig

func TestStartCollectorsMixedConfig(t *testing.T) {
	logrus.SetLevel(logrus.ErrorLevel)
	conf, _ := config.ReadConfig(tmpTestFakeFile)
	collectors := startCollectors(conf)

	for _, c := range collectors {
		assert.Equal(t, c.Name(), "Test", "Only create valid collectors")
	}
}
開發者ID:EvanKrall,項目名稱:fullerite,代碼行數:9,代碼來源:collectors_test.go

示例5: visualize

func visualize(ctx *cli.Context) {
	initLogrus(ctx)
	log.Info("Visualizing fullerite...")

	if len(ctx.Args()) == 0 {
		log.Error("You need a collector file to visualize!, see 'fullerite help visualize'")
		return
	}

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}

	// Setup AdHoc Collector config from context and args
	collectorFile, _ := filepath.Abs(ctx.Args()[0])
	configMap := make(map[string]interface{})
	configMap["interval"] = ctx.Int("interval")
	configMap["collectorFile"] = collectorFile

	// Start collector and handlers
	collector := startCollector("AdHoc", c, configMap)
	handlers := startHandlers(c)

	// Create channel for incoming metrics
	metrics := make(chan metric.Metric)
	defer close(metrics)

	// Read the metrics from the AdHoc collector
	go readFromCollector(collector, metrics)
	go relayMetricsToHandlers(handlers, metrics)

	// Stop collecting after `die-after` duration expires
	quitChannel := make(chan bool, 1)
	defer close(quitChannel)

	dieAfter := time.Duration(ctx.Int("die-after"))
	time.AfterFunc(dieAfter*time.Second, func() {
		log.Info("Quitting...")
		quitChannel <- true
	})
	// Wait to quit
	for {
		select {
		case <-quitChannel:
			return
		}
	}
}
開發者ID:carriercomm,項目名稱:fullerite,代碼行數:49,代碼來源:main.go

示例6: start

func start(ctx *cli.Context) {
	initLogrus(ctx)
	log.Info("Starting beatit...")

	runtime.GOMAXPROCS(runtime.NumCPU())

	c, err := config.ReadConfig(ctx.String("config"))
	if err != nil {
		return
	}

	var handlers []handler.Handler
	for i := 0; i < ctx.Int("num-tasks"); i++ {
		if ctx.Bool("graphite") {
			h := newHandler("Graphite", c, ctx.Int("num-datapoints"))
			go h.Run()
			handlers = append(handlers, h)
		}
		if ctx.Bool("signalfx") {
			h := newHandler("SignalFx", c, ctx.Int("num-datapoints"))
			go h.Run()
			handlers = append(handlers, h)
		}
		if ctx.Bool("datadog") {
			h := newHandler("Datadog", c, ctx.Int("num-datapoints"))
			go h.Run()
			handlers = append(handlers, h)
		}
	}

	t := time.Tick(1 * time.Second)
	count := 0
	for _ = range t {
		if count++; count > ctx.Int("time") {
			os.Exit(0)
		}
		metrics := generateMetrics(ctx.String("prefix"),
			ctx.Int("num-metrics"),
			ctx.Int("num-datapoints"),
			ctx.Bool("randomize"))
		for _, h := range handlers {
			go sendMetrics(h, metrics)
		}
	}
}
開發者ID:sagar8192,項目名稱:fullerite,代碼行數:45,代碼來源:main.go

示例7: TestParseBadConfig

func TestParseBadConfig(t *testing.T) {
	_, err := config.ReadConfig(tmpTestBadFile)
	assert.NotNil(t, err, "should fail")
}
開發者ID:jp2007,項目名稱:fullerite,代碼行數:4,代碼來源:config_test.go

示例8: TestParseGoodConfig

func TestParseGoodConfig(t *testing.T) {
	_, err := config.ReadConfig(tmpTestGoodFile)
	assert.Nil(t, err, "should succeed")
}
開發者ID:jp2007,項目名稱:fullerite,代碼行數:4,代碼來源:config_test.go


注:本文中的fullerite/config.ReadConfig函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。