task-processor/config/config.go

67 lines
1.3 KiB
Go
Raw Permalink Normal View History

2026-02-18 15:53:29 +03:00
package config
2026-02-18 19:58:09 +03:00
import "time"
2026-02-18 15:53:29 +03:00
type Config struct {
App App
Http Http
TasksSource TasksSource
2026-02-21 16:56:40 +03:00
Rabbit Rabbit
2026-02-18 15:53:29 +03:00
}
type App struct {
2026-02-18 19:58:09 +03:00
Mode string
LogLvl string
CheckPeriod time.Duration
2026-02-21 16:56:40 +03:00
ProcChanLen uint
2026-02-18 15:53:29 +03:00
}
type Http struct {
Host string
Port string
}
type TasksSource struct {
2026-02-18 19:58:09 +03:00
Host string
Port string
Timeout time.Duration
2026-02-18 15:53:29 +03:00
}
2026-02-21 16:56:40 +03:00
type Rabbit struct {
Host string
Port string
User string
Pass string
Vhost string
}
2026-02-18 15:53:29 +03:00
func NewConfig() Config {
return Config{
App: App{
2026-02-18 19:58:09 +03:00
Mode: getEnv("APP_MODE", "dev"),
LogLvl: getEnv("APP_LOG_LVL", "debug"),
CheckPeriod: getEnvSeconds("APP_CHECK_PERIOD_SECONDS", 20),
2026-02-21 16:56:40 +03:00
ProcChanLen: getEnvUint("APP_PROCESSOR_CHANNEL_SIZE", 100),
2026-02-18 15:53:29 +03:00
},
Http: Http{
2026-02-18 19:58:09 +03:00
Host: getEnv("HTTP_HOST", "0.0.0.0"),
Port: getEnv("HTTP_PORT", "41082"),
2026-02-18 15:53:29 +03:00
},
TasksSource: TasksSource{
2026-02-21 16:56:40 +03:00
Host: getEnv("TASK_API_HOST", "127.0.0.1"),
Port: getEnv("TASK_API_PORT", "61000"),
2026-02-18 19:58:09 +03:00
Timeout: getEnvSeconds("TASK_SOURCE_TIMEOUT_SECONDS", 60),
2026-02-18 15:53:29 +03:00
},
2026-02-21 16:56:40 +03:00
Rabbit: Rabbit{
Host: getEnv("RABBIT_HOST", "10.0.0.4"),
Port: getEnv("RABBIT_PORT", "5672"),
User: getEnv("RABBIT_USER", "taskProcessorDev"),
Pass: getEnv("RABBIT_PASS", "pass1234"),
Vhost: getEnv("RABBIT_VHOST", "taskProcessorDevHost"),
},
2026-02-18 15:53:29 +03:00
}
}