feat: rename env var

This commit is contained in:
Yanislav Igonin 2022-02-06 19:37:20 +02:00
parent aafbf6b1fe
commit 164f41ed9e
4 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
ENV=debug ENV=debug
PORT=3000 PORT=3000
SEED_DB=true IS_DB_SEEDED=true
IS_RATE_LIMITER_ENABLED=true IS_RATE_LIMITER_ENABLED=true
THREADS_MAX_COUNT=50 THREADS_MAX_COUNT=50
POSTGRES_URL=postgres://localhost/micrach?pool_max_conns=5 POSTGRES_URL=postgres://localhost/micrach?pool_max_conns=5

View File

@ -10,7 +10,7 @@ import (
type AppConfig struct { type AppConfig struct {
Env string Env string
Port int Port int
SeedDb bool IsDbSeeded bool
IsRateLimiterEnabled bool IsRateLimiterEnabled bool
ThreadsMaxCount int ThreadsMaxCount int
ThreadBumpLimit int ThreadBumpLimit int
@ -49,7 +49,7 @@ func getValueOrDefaultString(value string, defaultValue string) string {
func getAppConfig() AppConfig { func getAppConfig() AppConfig {
env := getValueOrDefaultString(os.Getenv("ENV"), "release") env := getValueOrDefaultString(os.Getenv("ENV"), "release")
port := getValueOrDefaultInt(os.Getenv("PORT"), 3000) port := getValueOrDefaultInt(os.Getenv("PORT"), 3000)
seedDb := getValueOrDefaultBoolean(os.Getenv("SEED_DB"), false) isDbSeeded := getValueOrDefaultBoolean(os.Getenv("IS_DB_SEEDED"), false)
isRateLimiterEnabled := getValueOrDefaultBoolean(os.Getenv("IS_RATE_LIMITER_ENABLED"), true) isRateLimiterEnabled := getValueOrDefaultBoolean(os.Getenv("IS_RATE_LIMITER_ENABLED"), true)
threadsMaxCount := getValueOrDefaultInt(os.Getenv("THREADS_MAX_COUNT"), 50) threadsMaxCount := getValueOrDefaultInt(os.Getenv("THREADS_MAX_COUNT"), 50)
threadBumpLimit := getValueOrDefaultInt(os.Getenv("THREAD_BUMP_LIMIT"), 500) threadBumpLimit := getValueOrDefaultInt(os.Getenv("THREAD_BUMP_LIMIT"), 500)
@ -58,7 +58,7 @@ func getAppConfig() AppConfig {
return AppConfig{ return AppConfig{
Env: env, Env: env,
Port: port, Port: port,
SeedDb: seedDb, IsDbSeeded: isDbSeeded,
IsRateLimiterEnabled: isRateLimiterEnabled, IsRateLimiterEnabled: isRateLimiterEnabled,
ThreadsMaxCount: threadsMaxCount, ThreadsMaxCount: threadsMaxCount,
ThreadBumpLimit: threadBumpLimit, ThreadBumpLimit: threadBumpLimit,

View File

@ -8,7 +8,7 @@ services:
environment: environment:
ENV: release ENV: release
PORT: ${PORT} PORT: ${PORT}
SEED_DB: ${SEED_DB} IS_DB_SEEDED: ${IS_DB_SEEDED}
IS_RATE_LIMITER_ENABLED: ${IS_RATE_LIMITER_ENABLED} IS_RATE_LIMITER_ENABLED: ${IS_RATE_LIMITER_ENABLED}
THREADS_MAX_COUNT: ${THREADS_MAX_COUNT} THREADS_MAX_COUNT: ${THREADS_MAX_COUNT}
POSTGRES_URL: ${POSTGRES_URL} POSTGRES_URL: ${POSTGRES_URL}

View File

@ -26,7 +26,7 @@ func main() {
Db.Migrate() Db.Migrate()
defer Db.Pool.Close() defer Db.Pool.Close()
gin.SetMode(Config.App.Env) gin.SetMode(Config.App.Env)
if Config.App.SeedDb { if Config.App.IsDbSeeded {
Repositories.Seed() Repositories.Seed()
} }