MCPcopy Create free account
hub / github.com/andersonmarquesgit/chargeback / LoadConfig

Function LoadConfig

chargeback-batch/internal/config/config.go:65–105  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

63}
64
65func LoadConfig() *Config {
66 return &Config{
67 Server: ServerConfig{
68 Port: getEnv("SERVER_PORT", "81"),
69 ReadTimeout: getEnvAsDuration("SERVER_READ_TIMEOUT", 15*time.Second),
70 WriteTimeout: getEnvAsDuration("SERVER_WRITE_TIMEOUT", 15*time.Second),
71 },
72 Database: DatabaseConfig{
73 DSN: getEnv("DSN", "host=localhost port=5432 user=admin password=admin dbname=batch sslmode=disable timezone=UTC connect_timeout=5"),
74 },
75 RabbitMQ: RabbitMQConfig{
76 URL: getEnv("RABBITMQ_URL", "amqp://guest:guest@localhost:5672"),
77 },
78 NewRelic: NewRelicConfig{
79 LicenseKey: getEnv("NEW_RELIC_LICENSE_KEY", ""),
80 Enabled: getEnvAsBool("NEW_RELIC_ENABLED", false),
81 },
82 Minio: MinioConfig{
83 Endpoint: getEnv("MINIO_ENDPOINT", "localhost:9000"),
84 AccessKey: getEnv("MINIO_ACCESS_KEY", "admin"),
85 SecretKey: getEnv("MINIO_SECRET_KEY", "password"),
86 UseSSL: false, // ou converter com strconv.ParseBool
87 BucketName: getEnv("MINIO_BUCKET_NAME", "chargebacks"),
88 },
89 FTP: FTPConfig{
90 Host: getEnv("FTP_HOST", "localhost"),
91 Port: getEnvAsInt("FTP_PORT", 21),
92 Username: getEnv("FTP_USER", "admin"),
93 Password: getEnv("FTP_PASS", "admin"),
94 },
95 Scheduler: SchedulerConfig{
96 Enabled: getEnvAsBool("SCHEDULER_ENABLED", true),
97 Interval: getEnvAsDurationWithUnit(
98 "SCHEDULER_INTERVAL_VALUE",
99 "SCHEDULER_INTERVAL_UNIT",
100 1*time.Minute, // default de 1 min
101 ),
102 MaxFilesPerDay: getEnvAsInt("BATCH_MAX_FILES_PER_DAY", 4),
103 },
104 }
105}
106
107// Funções auxiliares para carregar variáveis de ambiente
108func getEnv(key string, defaultValue string) string {

Callers

nothing calls this directly

Calls 5

getEnvFunction · 0.70
getEnvAsDurationFunction · 0.70
getEnvAsBoolFunction · 0.70
getEnvAsIntFunction · 0.70
getEnvAsDurationWithUnitFunction · 0.70

Tested by

no test coverage detected