// GetOrDefaultSecond returns the given environment variable value as an time.Duration (second).
// Returns the default if the envvar cannot be coopered to an int, or is not found.
12725
func GetOrDefaultSecond(envVar string, defaultValue time.Duration) time.Duration {
	v := GetOrDefaultInt(envVar, -1)
	if v < 0 {
		return defaultValue
	}

	return time.Duration(v) * time.Second
}
510020
func (r *Store) GetInt32Default(key string, def int32) int32 {
	if v, err := r.GetInt32(key); err == nil {
		return v
	}

	return def
}
421162
func GetFloat64OrDefault(key string, defVal float64) float64 {
	viperLock.RLock()
	defer viperLock.RUnlock()

	if val := viper.GetFloat64(key); val != 0 {
		return val
	}

	return defVal
}
1297660
func (l *LogOptions) GetStringDefault(option, value string) string {
	if v, found := l.ExtendedOptions[option]; found {
		return v.(string)
	}
	return value
}
179058
func (ec *Envcfg) GetDuration(key string) time.Duration {
	d, _ := time.ParseDuration(ec.GetKey(key))
	return d
}
444817
func (s *spiConfig) GetBusOrDefault(d int) int {
	if s.bus == NotInitialized {
		return d
	}
	return s.bus
}
1024046
func (r *Store) GetInt64Default(key string, def int64) int64 {
	if v, err := r.GetInt64(key); err == nil {
		return v
	}

	return def
}
1288425
func (t *TimePeriod) ToSeconds() (int64, error) {
	if t == nil {
		return 0, nil
	}
	switch t := t.Time.(type) {
	case *TimePeriod_Duration:
		return t.ToSeconds()
	case *TimePeriod_Seconds:
		return t.Seconds, nil
	default:
		return 0, errors.Reason("unexpected type %T", t).Err()
	}
}
933131
func GetOrDefaultInt(envVar string, defaultValue int) int {
	v, err := strconv.Atoi(GetOrFile(envVar))
	if err != nil {
		return defaultValue
	}

	return v
}
1242749
func DefaultBackoff(base, max float64, retries int) time.Duration {
	return Backoff(base, max, .2, 1.6, retries)
}
136892
func (this *Future) GetOrTimeout(mm uint) (val interface{}, err error, timout bool) {
	if mm == 0 {
		mm = 10
	} else {
		mm = mm * 1000 * 1000
	}

	select {
	case <-time.After((time.Duration)(mm) * time.Nanosecond):
		return nil, nil, true
	case <-this.final:
		r, err := getFutureReturnVal(this.loadResult())
		return r, err, false
	}
}
663013
func (i *i2cConfig) GetBusOrDefault(d int) int {
	if i.bus == BusNotInitialized {
		return d
	}

	return i.bus
}
1189833
func getDefaultConfig() *Config {
	return &Config{
		LogLevel:    defaultLogLevel,
		GoMaxProcs:  defaultGoMaxProcs,
		LogPath:     defaultLogPath,
		LogTruncate: defaultLogTruncate,
		LogColors:   defaultLogColors,
		Control:     control.GetDefaultConfig(),
		Scheduler:   scheduler.GetDefaultConfig(),
		RestAPI:     rest.GetDefaultConfig(),
		Tribe:       tribe.GetDefaultConfig(),
	}
}
801799
func (t *Tree) GetDefault(key string, def interface{}) interface{} {
	val := t.Get(key)
	if val == nil {
		return def
	}
	return val
}
951420
func GetDefaultConfig() *Config {
	return &Config{
		ListenAddr:        defaultListenAddr,
		ListenPort:        defaultListenPort,
		MaxRunningPlugins: defaultMaxRunningPlugins,
		PluginLoadTimeout: defaultPluginLoadTimeout,
		PluginTrust:       defaultPluginTrust,
		AutoDiscoverPath:  defaultAutoDiscoverPath,
		KeyringPaths:      defaultKeyringPaths,
		CacheExpiration:   jsonutil.Duration{defaultCacheExpiration},
		Plugins:           newPluginConfig(),
		Tags:              newPluginTags(),
		Pprof:             defaultPprof,
		MaxPluginRestarts: MaxPluginRestartCount,
		TempDirPath:       defaultTempDirPath,
		TLSCertPath:       defaultTLSCertPath,
		TLSKeyPath:        defaultTLSKeyPath,
		CACertPaths:       defaultCACertPaths,
	}
}
442209
func GetDefault(key, defaultValue string) string {
	val := os.Getenv(key)
	if val == "" {
		return defaultValue
	}

	return val
}
620437
func (c *Conn) ParseDefaultConfigEnv() error {
	ret := C.rados_conf_parse_env(c.cluster, nil)
	if ret == 0 {
		return nil
	} else {
		return RadosError(int(ret))
	}
}