Example #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", "", "name of the coordinator")
	flagSet.StringP("socket_dir", "s", "/tmp/mistify", "base directory in which to create task sockets")
	flagSet.UintP("external_port", "p", 8080, "port for the http external request server to listen")
	flagSet.StringP("log_level", "l", "warning", "log level: debug/info/warn/error/fatal/panic")
	flagSet.UintP("request_timeout", "t", 0, "default timeout for requests in seconds")

	return &Config{
		viper:   v,
		flagSet: flagSet,
	}
}
Example #2
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,
	}
}