本文整理汇总了Golang中github.com/influxdb/influxdb/services/graphite.NewConfig函数的典型用法代码示例。如果您正苦于以下问题:Golang NewConfig函数的具体用法?Golang NewConfig怎么用?Golang NewConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewConfig函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestConfigValidateTooManyField
func TestConfigValidateTooManyField(t *testing.T) {
c := graphite.NewConfig()
c.Templates = []string{"a measurement b c"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
}
开发者ID:tcompart,项目名称:influxdb,代码行数:7,代码来源:config_test.go
示例2: TestConfigValidateTemplatePatterns
func TestConfigValidateTemplatePatterns(t *testing.T) {
c := graphite.NewConfig()
c.Templates = []string{"*measurement"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Templates = []string{".host.region"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
}
开发者ID:tcompart,项目名称:influxdb,代码行数:12,代码来源:config_test.go
示例3: TestConfigValidateEmptyTemplate
func TestConfigValidateEmptyTemplate(t *testing.T) {
c := graphite.NewConfig()
c.Templates = []string{""}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Templates = []string{" "}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
}
开发者ID:tcompart,项目名称:influxdb,代码行数:12,代码来源:config_test.go
示例4: TestConfigValidateFilterDuplicates
func TestConfigValidateFilterDuplicates(t *testing.T) {
c := graphite.NewConfig()
c.Templates = []string{"foo measurement*", "foo .host.measurement"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
// duplicate default templates
c.Templates = []string{"measurement*", ".host.measurement"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
}
开发者ID:tcompart,项目名称:influxdb,代码行数:14,代码来源:config_test.go
示例5: TestConfigValidateFilter
func TestConfigValidateFilter(t *testing.T) {
c := graphite.NewConfig()
c.Templates = []string{".server measurement*"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Templates = []string{". .server measurement*"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Templates = []string{"server* measurement*"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
}
开发者ID:tcompart,项目名称:influxdb,代码行数:17,代码来源:config_test.go
示例6: Test_ServerGraphiteTCPTimeout
func Test_ServerGraphiteTCPTimeout(t *testing.T) {
t.Parallel()
config := graphite.NewConfig()
config.Database = "graphitedb"
config.BindAddress = ":0"
config.TCPTimeout = toml.Duration(100 * time.Millisecond)
service, err := graphite.NewService(config)
if err != nil {
t.Fatalf("failed to create Graphite service: %s", err.Error())
}
pointsWriter := PointsWriter{
WritePointsFn: func(req *cluster.WritePointsRequest) error {
return nil
},
}
service.PointsWriter = &pointsWriter
dbCreator := DatabaseCreator{}
service.MetaStore = &dbCreator
if err := service.Open(); err != nil {
t.Fatalf("failed to open Graphite service: %s", err.Error())
}
if !dbCreator.Created {
t.Fatalf("failed to create target database")
}
// Connect to the graphite endpoint we just spun up
_, port, _ := net.SplitHostPort(service.Addr().String())
conn, err := net.Dial("tcp", "127.0.0.1:"+port)
if err != nil {
t.Fatal(err)
}
// The only way to be sure a connection has closed is to try reading from it.
time.Sleep(200 * time.Millisecond)
data := make([]byte, 256)
_, err = conn.Read(data)
if err != io.EOF {
t.Fatal("expected Graphite write timeout error")
}
}
开发者ID:KoeSystems,项目名称:influxdb,代码行数:45,代码来源:service_test.go
示例7: NewConfig
// NewConfig returns an instance of Config with reasonable defaults.
func NewConfig() *Config {
c := &Config{}
c.Meta = meta.NewConfig()
c.Data = tsdb.NewConfig()
c.Cluster = cluster.NewConfig()
c.Precreator = precreator.NewConfig()
c.Admin = admin.NewConfig()
c.HTTPD = httpd.NewConfig()
c.Collectd = collectd.NewConfig()
c.OpenTSDB = opentsdb.NewConfig()
c.Graphites = append(c.Graphites, graphite.NewConfig())
c.Monitoring = monitor.NewConfig()
c.ContinuousQuery = continuous_querier.NewConfig()
c.Retention = retention.NewConfig()
c.HintedHandoff = hh.NewConfig()
return c
}
开发者ID:marcosnils,项目名称:influxdb,代码行数:21,代码来源:config.go
示例8: TestConfigValidateDefaultTags
func TestConfigValidateDefaultTags(t *testing.T) {
c := graphite.NewConfig()
c.Tags = []string{"foo"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Tags = []string{"foo=bar="}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Tags = []string{"foo=bar", ""}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Tags = []string{"="}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
}
开发者ID:tcompart,项目名称:influxdb,代码行数:22,代码来源:config_test.go
示例9: TestConfigValidateTemplateTags
func TestConfigValidateTemplateTags(t *testing.T) {
c := graphite.NewConfig()
c.Templates = []string{"*.server measurement* foo"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Templates = []string{"*.server measurement* foo=bar="}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Templates = []string{"*.server measurement* foo=bar,"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
c.Templates = []string{"*.server measurement* ="}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
}
开发者ID:tcompart,项目名称:influxdb,代码行数:22,代码来源:config_test.go
示例10: NewConfig
// NewConfig returns an instance of Config with reasonable defaults.
func NewConfig() *Config {
c := &Config{}
c.Meta = meta.NewConfig()
c.Data = tsdb.NewConfig()
c.Cluster = cluster.NewConfig()
c.Registration = registration.NewConfig()
c.Precreator = precreator.NewConfig()
c.Admin = admin.NewConfig()
c.Monitor = monitor.NewConfig()
c.Subscriber = subscriber.NewConfig()
c.HTTPD = httpd.NewConfig()
c.Graphites = []graphite.Config{graphite.NewConfig()}
c.Collectd = collectd.NewConfig()
c.OpenTSDB = opentsdb.NewConfig()
c.UDPs = []udp.Config{udp.NewConfig()}
c.ContinuousQuery = continuous_querier.NewConfig()
c.Retention = retention.NewConfig()
c.HintedHandoff = hh.NewConfig()
return c
}
开发者ID:TuziBen,项目名称:influxdb,代码行数:24,代码来源:config.go
示例11: Test_ServerGraphiteUDP
func Test_ServerGraphiteUDP(t *testing.T) {
t.Parallel()
now := time.Now().UTC().Round(time.Second)
config := graphite.NewConfig()
config.Database = "graphitedb"
config.BatchSize = 0 // No batching.
config.BatchTimeout = toml.Duration(time.Second)
config.BindAddress = ":10000"
config.Protocol = "udp"
service, err := graphite.NewService(config)
if err != nil {
t.Fatalf("failed to create Graphite service: %s", err.Error())
}
// Allow test to wait until points are written.
var wg sync.WaitGroup
wg.Add(1)
pointsWriter := PointsWriter{
WritePointsFn: func(req *cluster.WritePointsRequest) error {
defer wg.Done()
if req.Database != "graphitedb" {
t.Fatalf("unexpected database: %s", req.Database)
} else if req.RetentionPolicy != "" {
t.Fatalf("unexpected retention policy: %s", req.RetentionPolicy)
} else if req.Points[0].String() !=
tsdb.NewPoint(
"cpu",
map[string]string{},
map[string]interface{}{"value": 23.456},
time.Unix(now.Unix(), 0)).String() {
t.Fatalf("unexpected points: %#v", req.Points[0].String())
}
return nil
},
}
service.PointsWriter = &pointsWriter
dbCreator := DatabaseCreator{}
service.MetaStore = &dbCreator
if err := service.Open(); err != nil {
t.Fatalf("failed to open Graphite service: %s", err.Error())
}
if !dbCreator.Created {
t.Fatalf("failed to create target database")
}
// Connect to the graphite endpoint we just spun up
_, port, _ := net.SplitHostPort(service.Addr().String())
conn, err := net.Dial("udp", "127.0.0.1:"+port)
if err != nil {
t.Fatal(err)
}
data := []byte(`cpu 23.456 `)
data = append(data, []byte(fmt.Sprintf("%d", now.Unix()))...)
data = append(data, '\n')
_, err = conn.Write(data)
if err != nil {
t.Fatal(err)
}
wg.Wait()
conn.Close()
}
开发者ID:nibosho,项目名称:telegraf,代码行数:69,代码来源:service_test.go
注:本文中的github.com/influxdb/influxdb/services/graphite.NewConfig函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论