new fields
This commit is contained in:
parent
ca36d84a03
commit
f6e99b2b65
3 changed files with 41 additions and 15 deletions
|
|
@ -1,6 +1,11 @@
|
|||
package config
|
||||
|
||||
import "os"
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func getEnv(key, fallback string) string {
|
||||
if value, ok := os.LookupEnv(key); ok {
|
||||
|
|
@ -8,3 +13,16 @@ func getEnv(key, fallback string) string {
|
|||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
func getEnvSeconds(key string, fallback int) time.Duration {
|
||||
if value, ok := os.LookupEnv(key); ok {
|
||||
num, err := strconv.Atoi(value)
|
||||
if err != nil {
|
||||
log.Printf("Error converting %v to int, using default value - 60 seconds", key)
|
||||
return time.Duration(60) * time.Second
|
||||
}
|
||||
|
||||
return time.Duration(num) * time.Second
|
||||
}
|
||||
return time.Duration(fallback) * time.Second
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue