config ext

This commit is contained in:
nquidox 2026-04-03 20:52:53 +03:00
parent e77521f3aa
commit 3fcd25b769
2 changed files with 17 additions and 6 deletions

View file

@ -1,14 +1,19 @@
package config package config
import "runtime"
type Config struct { type Config struct {
App AppConfig App AppConfig
Rabbit RabbitMQConfig Rabbit RabbitMQConfig
} }
type AppConfig struct { type AppConfig struct {
Mode string Mode string
LogLvl string LogLvl string
ChanLen uint ChanLen uint
ExternalBrowser string
NumCPUs int
TaskTimeoutSeconds int
} }
type RabbitMQConfig struct { type RabbitMQConfig struct {
@ -25,9 +30,12 @@ type RabbitMQConfig struct {
func New() *Config { func New() *Config {
return &Config{ return &Config{
App: AppConfig{ App: AppConfig{
Mode: getEnv("APP_MODE", "dev"), Mode: getEnv("APP_MODE", "dev"),
LogLvl: getEnv("APP_LOG_LVL", "debug"), LogLvl: getEnv("APP_LOG_LVL", "debug"),
ChanLen: getEnvUint("APP_CHANNEL_LEN", 100), ChanLen: getEnvUint("APP_CHANNEL_LEN", 100),
ExternalBrowser: getEnv("APP_EXTERNAL_BROWSER", "http://10.0.0.4:13000"),
NumCPUs: getEnvInt("APP_NUMCPUS", runtime.NumCPU()),
TaskTimeoutSeconds: getEnvInt("APP_TASK_TIMEOUT_SECONDS", 60),
}, },
Rabbit: RabbitMQConfig{ Rabbit: RabbitMQConfig{

View file

@ -1,6 +1,9 @@
APP_MODE=dev APP_MODE=dev
APP_LOG_LVL=debug APP_LOG_LVL=debug
APP_CHANNEL_LEN=100 APP_CHANNEL_LEN=100
APP_NUMCPUS=
APP_EXTERNAL_BROWSER=
APP_TASK_TIMEOUT_SECONDS=
RABBIT_HOST= RABBIT_HOST=
RABBIT_PORT= RABBIT_PORT=