// NewCommand returns a new instance of Command with default settings. func NewCommand() *Command { return &Command{ Stdout: os.Stdout, Stderr: os.Stderr, MetaConfig: meta.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.Monitor = monitor.NewConfig() c.Subscriber = subscriber.NewConfig() c.HTTPD = httpd.NewConfig() c.Collectd = collectd.NewConfig() c.OpenTSDB = opentsdb.NewConfig() c.ContinuousQuery = continuous_querier.NewConfig() c.Retention = retention.NewConfig() c.HintedHandoff = hh.NewConfig() c.BindAddress = DefaultBindAddress // All ARRAY attributes have to be init after toml decode // See: https://github.com/BurntSushi/toml/pull/68 // Those attributes will be initialized in Config.InitTableAttrs method // Concerned Attributes: // * `c.Graphites` // * `c.UDPs` return c }
func newConfig() *meta.Config { cfg := meta.NewConfig() cfg.BindAddress = "127.0.0.1:0" cfg.HTTPBindAddress = "127.0.0.1:0" cfg.Dir = testTempDir(2) cfg.LeaseDuration = toml.Duration(1 * time.Second) return cfg }
// parseFlags parses and validates the command line arguments. func (cmd *Command) parseFlags(args []string) error { fs := flag.NewFlagSet("", flag.ContinueOnError) fs.StringVar(&cmd.metadir, "metadir", "", "") fs.StringVar(&cmd.datadir, "datadir", "", "") fs.StringVar(&cmd.database, "database", "", "") fs.StringVar(&cmd.retention, "retention", "", "") fs.StringVar(&cmd.shard, "shard", "", "") fs.SetOutput(cmd.Stdout) fs.Usage = cmd.printUsage if err := fs.Parse(args); err != nil { return err } cmd.MetaConfig = meta.NewConfig() cmd.MetaConfig.Dir = cmd.metadir // Require output path. cmd.backupFilesPath = fs.Arg(0) if cmd.backupFilesPath == "" { return fmt.Errorf("path with backup files required") } // validate the arguments if cmd.metadir == "" && cmd.database == "" { return fmt.Errorf("-metadir or -database are required to restore") } if cmd.database != "" && cmd.datadir == "" { return fmt.Errorf("-datadir is required to restore") } if cmd.shard != "" { if cmd.database == "" { return fmt.Errorf("-database is required to restore shard") } if cmd.retention == "" { return fmt.Errorf("-retention is required to restore shard") } } else if cmd.retention != "" && cmd.database == "" { return fmt.Errorf("-database is required to restore retention policy") } return nil }
// 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.Monitor = monitor.NewConfig() c.Subscriber = subscriber.NewConfig() c.HTTPD = httpd.NewConfig() c.Collectd = collectd.NewConfig() c.OpenTSDB = opentsdb.NewConfig() c.ContinuousQuery = continuous_querier.NewConfig() c.Retention = retention.NewConfig() c.HintedHandoff = hh.NewConfig() c.BindAddress = DefaultBindAddress return c }
// NewConfig returns an instance of Config with reasonable defaults. func NewConfig() *Config { c := &Config{} c.Meta = meta.NewConfig() c.Data = tsdb.NewConfig() c.Coordinator = coordinator.NewConfig() c.Precreator = precreator.NewConfig() c.Admin = admin.NewConfig() c.Monitor = monitor.NewConfig() c.Subscriber = subscriber.NewConfig() c.HTTPD = httpd.NewConfig() c.GraphiteInputs = []graphite.Config{graphite.NewConfig()} c.CollectdInputs = []collectd.Config{collectd.NewConfig()} c.OpenTSDBInputs = []opentsdb.Config{opentsdb.NewConfig()} c.UDPInputs = []udp.Config{udp.NewConfig()} c.ContinuousQuery = continuous_querier.NewConfig() c.Retention = retention.NewConfig() c.BindAddress = DefaultBindAddress return c }
func newConfig() *meta.Config { cfg := meta.NewConfig() cfg.Dir = testTempDir(2) cfg.DefaultRetentionPolicyName = "default" return cfg }
func newConfig() *meta.Config { cfg := meta.NewConfig() cfg.Dir = testTempDir(2) return cfg }