47 lines
831 B
Go
47 lines
831 B
Go
package config
|
|
|
|
import "time"
|
|
|
|
type Config struct {
|
|
App App
|
|
Http Http
|
|
TasksSource TasksSource
|
|
}
|
|
|
|
type App struct {
|
|
Mode string
|
|
LogLvl string
|
|
CheckPeriod time.Duration
|
|
}
|
|
|
|
type Http struct {
|
|
Host string
|
|
Port string
|
|
}
|
|
|
|
type TasksSource struct {
|
|
Host string
|
|
Port string
|
|
Timeout time.Duration
|
|
}
|
|
|
|
func NewConfig() Config {
|
|
return Config{
|
|
App: App{
|
|
Mode: getEnv("APP_MODE", "dev"),
|
|
LogLvl: getEnv("APP_LOG_LVL", "debug"),
|
|
CheckPeriod: getEnvSeconds("APP_CHECK_PERIOD_SECONDS", 20),
|
|
},
|
|
|
|
Http: Http{
|
|
Host: getEnv("HTTP_HOST", "0.0.0.0"),
|
|
Port: getEnv("HTTP_PORT", "41082"),
|
|
},
|
|
|
|
TasksSource: TasksSource{
|
|
Host: getEnv("TASK_API_HOST", ""),
|
|
Port: getEnv("TASK_API_PORT", ""),
|
|
Timeout: getEnvSeconds("TASK_SOURCE_TIMEOUT_SECONDS", 60),
|
|
},
|
|
}
|
|
}
|