Ejemplo n.º 1
0
// NewConfig creates a new instance of Config. If a viper instance is not
// provided, a new one will be created.
func NewConfig(flagSet *flag.FlagSet, v *viper.Viper) *Config {
	if flagSet == nil {
		flagSet = flag.CommandLine
	}

	if v == nil {
		v = viper.New()
	}

	flagSet.StringP("config_file", "c", "", "path to config file")
	flagSet.StringP("service_name", "n", "", "provider service name")
	flagSet.StringP("socket_dir", "s", "/tmp/mistify", "base directory in which to create task sockets")
	flagSet.UintP("default_priority", "p", 50, "default task priority")
	flagSet.StringP("coordinator_url", "u", "", "url of coordinator for making requests")
	flagSet.StringP("log_level", "l", "warning", "log level: debug/info/warn/error/fatal/panic")
	flagSet.Uint64P("request_timeout", "t", 0, "default timeout for requests made by this provider in seconds")

	return &Config{
		viper:   v,
		flagSet: flagSet,
	}
}