本文整理汇总了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;未经允许,请勿转载。 |
请发表评论