task-processor/config/helper.go
2026-02-18 19:58:09 +03:00

28 lines
586 B
Go

package config
import (
log "github.com/sirupsen/logrus"
"os"
"strconv"
"time"
)
func getEnv(key, fallback string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
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
}