task-processor/config/config.go

71 lines
1.6 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 {
2026-04-08 12:15:24 +03:00
Host string
Port uint16
User string
Pass string
Vhost string
LoggingEnabled bool
2026-02-21 16:56:40 +03:00
}
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"),
2026-04-03 11:45:22 +03:00
CheckPeriod: getEnvSeconds("APP_CHECK_PERIOD_SECONDS", 60*60*6),
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-04-08 12:15:24 +03:00
//Host: getEnv("TASK_SOURCE_HOST", "127.0.0.1"),
//Port: getEnv("TASK_SOURCE_PORT", "61000"),
Host: getEnv("TASK_SOURCE_HOST", "10.0.0.1"),
Port: getEnv("TASK_SOURCE_PORT", "9099"),
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{
2026-04-08 12:15:24 +03:00
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"),
LoggingEnabled: getEnvBool("RABBIT_LOGGING_ENABLED", true),
2026-02-21 16:56:40 +03:00
},
2026-02-18 15:53:29 +03:00
}
}