func NewConfig() Config { return Config{ MaxWALSize: DefaultMaxWALSize, WALFlushInterval: toml.Duration(DefaultWALFlushInterval), WALPartitionFlushDelay: toml.Duration(DefaultWALPartitionFlushDelay), } }
// NewConfig returns a new Config with defaults. func NewConfig() Config { return Config{ Enabled: true, CheckInterval: toml.Duration(DefaultCheckInterval), AdvancePeriod: toml.Duration(DefaultAdvancePeriod), } }
func NewConfig() Config { return Config{ Enabled: true, MaxSize: DefaultMaxSize, MaxAge: toml.Duration(DefaultMaxAge), RetryRateLimit: DefaultRetryRateLimit, RetryInterval: toml.Duration(DefaultRetryInterval), } }
// NewConfig returns a new instance of Config with defaults. func NewConfig() Config { return Config{ Enabled: true, RecomputePreviousN: DefaultRecomputePreviousN, RecomputeNoOlderThan: toml.Duration(DefaultRecomputeNoOlderThan), ComputeRunsPerInterval: DefaultComputeRunsPerInterval, ComputeNoMoreThan: toml.Duration(DefaultComputeNoMoreThan), } }
func NewConfig() Config { return Config{ Hostname: DefaultHostname, BindAddress: DefaultBindAddress, RetentionAutoCreate: true, ElectionTimeout: toml.Duration(DefaultElectionTimeout), HeartbeatTimeout: toml.Duration(DefaultHeartbeatTimeout), LeaderLeaseTimeout: toml.Duration(DefaultLeaderLeaseTimeout), CommitTimeout: toml.Duration(DefaultCommitTimeout), } }
// NewConfig returns the default test configuration. func NewConfig(path string) meta.Config { return meta.Config{ Dir: path, Hostname: "localhost", BindAddress: "127.0.0.1:0", HeartbeatTimeout: toml.Duration(500 * time.Millisecond), ElectionTimeout: toml.Duration(500 * time.Millisecond), LeaderLeaseTimeout: toml.Duration(500 * time.Millisecond), CommitTimeout: toml.Duration(5 * time.Millisecond), } }
// NewConfig returns the default config with temporary paths. func NewConfig() *run.Config { c := run.NewConfig() c.Meta.Dir = MustTempFile() c.Meta.BindAddress = "127.0.0.1:0" c.Meta.HeartbeatTimeout = toml.Duration(50 * time.Millisecond) c.Meta.ElectionTimeout = toml.Duration(50 * time.Millisecond) c.Meta.LeaderLeaseTimeout = toml.Duration(50 * time.Millisecond) c.Meta.CommitTimeout = toml.Duration(5 * time.Millisecond) c.Data.Dir = MustTempFile() c.HintedHandoff.Dir = MustTempFile() c.HTTPD.Enabled = true c.HTTPD.BindAddress = "127.0.0.1:0" c.HTTPD.LogEnabled = testing.Verbose() return c }
func Test_ShardPrecreation(t *testing.T) { t.Parallel() now := time.Now().UTC() advancePeriod := 5 * time.Minute // A test metastaore which returns 2 shard groups, only 1 of which requires a successor. var wg sync.WaitGroup wg.Add(1) ms := metaStore{ PrecreateShardGroupsFn: func(u time.Time) error { wg.Done() if u != now.Add(advancePeriod) { t.Fatalf("precreation called with wrong time, got %s, exp %s", u, now) } return nil }, } srv, err := NewService(Config{ CheckInterval: toml.Duration(time.Minute), AdvancePeriod: toml.Duration(advancePeriod), }) if err != nil { t.Fatalf("failed to create shard precreation service: %s", err.Error()) } srv.MetaStore = ms err = srv.precreate(now) if err != nil { t.Fatalf("failed to precreate shards: %s", err.Error()) } wg.Wait() // Ensure metastore test function is called. return }
// NewConfig returns an instance of Config with defaults. func NewConfig() Config { return Config{ WriteTimeout: toml.Duration(DefaultWriteTimeout), ShardWriterTimeout: toml.Duration(DefaultShardWriterTimeout), } }
func NewConfig() Config { return Config{ Enabled: false, WriteInterval: toml.Duration(DefaultStatisticsWriteInterval), } }
func NewConfig() Config { return Config{Enabled: true, CheckInterval: toml.Duration(10 * time.Minute)} }
import ( "time" "github.com/jportoles/influxdb092/toml" ) const ( DefaultBindAddress = ":25826" DefaultDatabase = "collectd" DefaultRetentionPolicy = "" DefaultBatchSize = 5000 DefaultBatchDuration = toml.Duration(10 * time.Second) DefaultTypesDB = "/usr/share/collectd/types.db" ) // Config represents a configuration for the collectd service. type Config struct { Enabled bool `toml:"enabled"` BindAddress string `toml:"bind-address"` Database string `toml:"database"` RetentionPolicy string `toml:"retention-policy"` BatchSize int `toml:"batch-size"` BatchDuration toml.Duration `toml:"batch-timeout"` TypesDB string `toml:"typesdb"` }
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 !reflect.DeepEqual(req.Points, []tsdb.Point{ tsdb.NewPoint( "cpu", map[string]string{}, map[string]interface{}{"value": 23.456}, time.Unix(now.Unix(), 0), ), }) { spew.Dump(req.Points) t.Fatalf("unexpected points: %#v", req.Points) } 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() }