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
PORT=3000
SEED_DB=true
IS_DB_SEEDED=true
IS_RATE_LIMITER_ENABLED=true
THREADS_MAX_COUNT=50
POSTGRES_URL=postgres://localhost/micrach?pool_max_conns=5

View File

@ -10,7 +10,7 @@ import (
type AppConfig struct {
Env string
Port int
SeedDb bool
IsDbSeeded bool
IsRateLimiterEnabled bool
ThreadsMaxCount int
ThreadBumpLimit int
@ -49,7 +49,7 @@ func getValueOrDefaultString(value string, defaultValue string) string {
func getAppConfig() AppConfig {
env := getValueOrDefaultString(os.Getenv("ENV"), "release")
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)
threadsMaxCount := getValueOrDefaultInt(os.Getenv("THREADS_MAX_COUNT"), 50)
threadBumpLimit := getValueOrDefaultInt(os.Getenv("THREAD_BUMP_LIMIT"), 500)
@ -58,7 +58,7 @@ func getAppConfig() AppConfig {
return AppConfig{
Env: env,
Port: port,
SeedDb: seedDb,
IsDbSeeded: isDbSeeded,
IsRateLimiterEnabled: isRateLimiterEnabled,
ThreadsMaxCount: threadsMaxCount,
ThreadBumpLimit: threadBumpLimit,

View File

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

View File

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