task-processor/config/config.go
2026-04-03 11:45:22 +03:00

66 lines
1.3 KiB
Go

package config
import "time"
type Config struct {
App App
Http Http
TasksSource TasksSource
Rabbit Rabbit
}
type App struct {
Mode string
LogLvl string
CheckPeriod time.Duration
ProcChanLen uint
}
type Http struct {
Host string
Port string
}
type TasksSource struct {
Host string
Port string
Timeout time.Duration
}
type Rabbit struct {
Host string
Port uint16
User string
Pass string
Vhost string
}
func NewConfig() Config {
return Config{
App: App{
Mode: getEnv("APP_MODE", "dev"),
LogLvl: getEnv("APP_LOG_LVL", "debug"),
CheckPeriod: getEnvSeconds("APP_CHECK_PERIOD_SECONDS", 60*60*6),
ProcChanLen: getEnvUint("APP_PROCESSOR_CHANNEL_SIZE", 100),
},
Http: Http{
Host: getEnv("HTTP_HOST", "0.0.0.0"),
Port: getEnv("HTTP_PORT", "41082"),
},
TasksSource: TasksSource{
Host: getEnv("TASK_API_HOST", "127.0.0.1"),
Port: getEnv("TASK_API_PORT", "61000"),
Timeout: getEnvSeconds("TASK_SOURCE_TIMEOUT_SECONDS", 60),
},
Rabbit: Rabbit{
Host: getEnv("RABBIT_HOST", "10.0.0.4"),
Port: getEnvPort("RABBIT_PORT", 5672),
User: getEnv("RABBIT_USER", "taskProcessorDev"),
Pass: getEnv("RABBIT_PASS", "pass1234"),
Vhost: getEnv("RABBIT_VHOST", "taskProcessorDevHost"),
},
}
}