Skip to content

Commit

Permalink
Removed unused Graphite NewConfig
Browse files Browse the repository at this point in the history
This function is not helpful for sections of the config that support
multiple instances.
  • Loading branch information
otoolep committed Sep 8, 2015
1 parent bbc1033 commit 332ce64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 22 deletions.
13 changes: 0 additions & 13 deletions services/graphite/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,6 @@ type Config struct {
Separator string `toml:"separator"`
}

// NewConfig returns a new Config with defaults.
func NewConfig() Config {
return Config{
BindAddress: DefaultBindAddress,
Database: DefaultDatabase,
Protocol: DefaultProtocol,
BatchSize: DefaultBatchSize,
BatchTimeout: toml.Duration(DefaultBatchTimeout),
ConsistencyLevel: DefaultConsistencyLevel,
Separator: DefaultSeparator,
}
}

// WithDefaults takes the given config and returns a new config with any required
// default values set.
func (c *Config) WithDefaults() *Config {
Expand Down
14 changes: 7 additions & 7 deletions services/graphite/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ tags=["region=us-east"]
}

func TestConfigValidateEmptyTemplate(t *testing.T) {
c := graphite.NewConfig()
c := &graphite.Config{}
c.Templates = []string{""}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
Expand All @@ -64,15 +64,15 @@ func TestConfigValidateEmptyTemplate(t *testing.T) {
}

func TestConfigValidateTooManyField(t *testing.T) {
c := graphite.NewConfig()
c := &graphite.Config{}
c.Templates = []string{"a measurement b c"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
}
}

func TestConfigValidateTemplatePatterns(t *testing.T) {
c := graphite.NewConfig()
c := &graphite.Config{}
c.Templates = []string{"*measurement"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
Expand All @@ -85,7 +85,7 @@ func TestConfigValidateTemplatePatterns(t *testing.T) {
}

func TestConfigValidateFilter(t *testing.T) {
c := graphite.NewConfig()
c := &graphite.Config{}
c.Templates = []string{".server measurement*"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
Expand All @@ -103,7 +103,7 @@ func TestConfigValidateFilter(t *testing.T) {
}

func TestConfigValidateTemplateTags(t *testing.T) {
c := graphite.NewConfig()
c := &graphite.Config{}
c.Templates = []string{"*.server measurement* foo"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
Expand All @@ -126,7 +126,7 @@ func TestConfigValidateTemplateTags(t *testing.T) {
}

func TestConfigValidateDefaultTags(t *testing.T) {
c := graphite.NewConfig()
c := &graphite.Config{}
c.Tags = []string{"foo"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
Expand All @@ -149,7 +149,7 @@ func TestConfigValidateDefaultTags(t *testing.T) {
}

func TestConfigValidateFilterDuplicates(t *testing.T) {
c := graphite.NewConfig()
c := &graphite.Config{}
c.Templates = []string{"foo measurement*", "foo .host.measurement"}
if err := c.Validate(); err == nil {
t.Errorf("config validate expected error. got nil")
Expand Down
4 changes: 2 additions & 2 deletions services/graphite/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func Test_ServerGraphiteTCP(t *testing.T) {

now := time.Now().UTC().Round(time.Second)

config := graphite.NewConfig()
config := graphite.Config{}
config.Database = "graphitedb"
config.BatchSize = 0 // No batching.
config.BatchTimeout = toml.Duration(time.Second)
Expand Down Expand Up @@ -87,7 +87,7 @@ func Test_ServerGraphiteUDP(t *testing.T) {

now := time.Now().UTC().Round(time.Second)

config := graphite.NewConfig()
config := graphite.Config{}
config.Database = "graphitedb"
config.BatchSize = 0 // No batching.
config.BatchTimeout = toml.Duration(time.Second)
Expand Down

0 comments on commit 332ce64

Please sign in to comment.