From f577dbcc7fccb747a5b86d1794a5e08d547b3780 Mon Sep 17 00:00:00 2001 From: Yanislav Igonin Date: Thu, 18 Nov 2021 10:36:06 +0200 Subject: [PATCH] add new var to config --- config/config.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index bfbafbd..0fe73fd 100644 --- a/config/config.go +++ b/config/config.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "log" "os" "strconv" ) @@ -11,6 +12,7 @@ type AppConfig struct { Port int SeedDb bool IsRateLimiterEnabled bool + ThreadsMaxCount int } type DbConfig struct { @@ -29,7 +31,7 @@ func getAppConfig() AppConfig { } port, err := strconv.Atoi(portString) if err != nil { - panic(fmt.Sprintf("Could not parse %s to int", portString)) + log.Panicln(fmt.Sprintf("Could not parse %s to int", portString)) } seedDbString := os.Getenv("SEED_DB") @@ -38,11 +40,18 @@ func getAppConfig() AppConfig { isRateLimiterEnabledString := os.Getenv("IS_RATE_LIMITER_ENABLED") isRateLimiterEnabled := isRateLimiterEnabledString == "true" + threadsMaxCountString := os.Getenv("THREADS_MAX_COUNT") + threadsMaxCount, err := strconv.Atoi(threadsMaxCountString) + if err != nil { + log.Panicln(fmt.Sprintf("Could not parse %s to int", threadsMaxCountString)) + } + return AppConfig{ Env: env, Port: port, SeedDb: seedDb, IsRateLimiterEnabled: isRateLimiterEnabled, + ThreadsMaxCount: threadsMaxCount, } }