core/internal/initialize/config.go

44 lines
1.8 KiB
Go

package initialize
import (
"github.com/caarlos0/env/v8"
"github.com/joho/godotenv"
"log"
)
type Config struct {
LoggerProdMode bool `env:"IS_PROD_LOG" envDefault:"false"`
IsProd bool `env:"IS_PROD" envDefault:"false"`
ClientHttpURL string `env:"CLIENT_HTTP_URL" envDefault:"0.0.0.0:1488"`
GrpcURL string `env:"GRPC_URL" envDefault:"localhost:9000"`
PostgresURL string `env:"POSTGRES_URL" envDefault:"host=localhost port=35432 user=squiz password=Redalert2 dbname=squiz sslmode=disable"`
ClickhouseURL string `env:"CLICKHOUSE_URL" envDefault:"tcp://10.8.0.15:9000/default?sslmode=disable"`
HubadminMicroserviceURL string `env:"HUBADMIN_MICROSERVICE_URL" envDefault:"http://localhost:8001/"`
AuthMicroserviceURL string `env:"AUTH_MICROSERVICE_URL" envDefault:"http://localhost:8000/"`
KafkaBrokers string `env:"KAFKA_BROKERS" envDefault:"localhost:9092"`
KafkaGroup string `env:"KAFKA_GROUP" envDefault:"mailnotifier"`
KafkaTopicNotifyer string `env:"KAFKA_TOPIC" envDefault:"test-topic"`
TrashLogHost string `env:"TRASH_LOG_HOST" envDefault:"localhost:7113"`
S3Prefix string `env:"S3_PREFIX"`
RedisHost string `env:"REDIS_HOST" envDefault:"localhost:6379"`
RedisPassword string `env:"REDIS_PASSWORD" envDefault:"admin"`
RedisDB uint64 `env:"REDIS_DB" envDefault:"2"`
CrtFile string `env:"CRT" envDefault:"server.crt"`
KeyFile string `env:"KEY" envDefault:"server.key"`
ServiceName string `env:"SERVICE_NAME" envDefault:"squiz"`
}
func LoadConfig() (*Config, error) {
if err := godotenv.Load(); err != nil {
log.Print("No .env file found")
}
var config Config
if err := env.Parse(&config); err != nil {
return nil, err
}
return &config, nil
}
const ModuleLogger = "core"