optimize cfg
This commit is contained in:
parent
b52103bf63
commit
7c0eb873b0
@ -72,7 +72,7 @@ func New(ctx context.Context, cfg initialize.Config, build Build) error {
|
||||
return zapcore.NewTee(core, clickHouseLogger)
|
||||
}))
|
||||
|
||||
loggerHlog := hlog.New(loggerForHlog).Module(cfg.ModuleLogger)
|
||||
loggerHlog := hlog.New(loggerForHlog).Module(initialize.ModuleLogger)
|
||||
loggerHlog.With(models.AllFields{})
|
||||
loggerHlog.Emit(InfoSvcStarted{})
|
||||
|
||||
@ -133,7 +133,7 @@ func New(ctx context.Context, cfg initialize.Config, build Build) error {
|
||||
})
|
||||
|
||||
go func() {
|
||||
if err := srv.Start(cfg.HttpHost + ":" + cfg.NumberPort); err != nil {
|
||||
if err := srv.Start(cfg.ClientHttpURL); err != nil {
|
||||
zapLogger.Error("HTTP server startup error", zap.Error(err))
|
||||
cancel()
|
||||
}
|
||||
|
@ -7,24 +7,22 @@ import (
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
LoggerProdMode bool `env:"IS_PROD_LOG" envDefault:"false"`
|
||||
IsProd bool `env:"IS_PROD" envDefault:"false"`
|
||||
MinioEP string `env:"MINIO_EP" envDefault:"localhost:3002"`
|
||||
MinioAK string `env:"MINIO_AK" envDefault:"minio"`
|
||||
MinioSK string `env:"MINIO_SK" envDefault:"miniostorage"`
|
||||
NumberPort string `env:"PORT" envDefault:"1490"`
|
||||
HttpHost string `env:"HTTP_HOST" envDefault:"0.0.0.0"`
|
||||
CrtFile string `env:"CRT" envDefault:"server.crt"`
|
||||
KeyFile string `env:"KEY" envDefault:"server.key"`
|
||||
PostgresCredentials string `env:"PG_CRED" envDefault:"host=localhost port=5432 user=squiz password=Redalert2 dbname=squiz sslmode=disable"`
|
||||
RedisHost string `env:"REDIS_HOST"`
|
||||
RedisPassword string `env:"REDIS_PASSWORD"`
|
||||
RedisDB uint64 `env:"REDIS_DB"`
|
||||
RedirectURL string `env:"REDIRECT_URL" envDefault:"https://squiz.pena.digital"`
|
||||
PubKey string `env:"PUBLIC_KEY"`
|
||||
PrivKey string `env:"PRIVATE_KEY"`
|
||||
TrashLogHost string `env:"TRASH_LOG_HOST" envDefault:"localhost:7113"`
|
||||
ModuleLogger string `env:"MODULE_LOGGER" envDefault:"answerer-local"`
|
||||
LoggerProdMode bool `env:"IS_PROD_LOG" envDefault:"false"`
|
||||
IsProd bool `env:"IS_PROD" envDefault:"false"`
|
||||
S3Endpoint string `env:"S3_ENDPOINT" envDefault:"localhost:3002"`
|
||||
S3AccessKey string `env:"S3_ACCESS_KEY" envDefault:"minio"`
|
||||
S3SecretKey string `env:"S3_SECRET_KEY" envDefault:"miniostorage"`
|
||||
ClientHttpURL string `env:"CLIENT_HTTP_URL" envDefault:"0.0.0.0:1490"`
|
||||
CrtFile string `env:"CRT" envDefault:"server.crt"`
|
||||
KeyFile string `env:"KEY" envDefault:"server.key"`
|
||||
PostgresURL string `env:"POSTGRES_URL" envDefault:"host=localhost port=5432 user=squiz password=Redalert2 dbname=squiz sslmode=disable"`
|
||||
RedisHost string `env:"REDIS_HOST"`
|
||||
RedisPassword string `env:"REDIS_PASSWORD"`
|
||||
RedisDB uint64 `env:"REDIS_DB"`
|
||||
RedirectURL string `env:"REDIRECT_URL" envDefault:"https://squiz.pena.digital"`
|
||||
PubKey string `env:"ENCRYPT_PUBLIC_KEY"`
|
||||
PrivKey string `env:"ENCRYPT_PRIVATE_KEY"`
|
||||
TrashLogHost string `env:"TRASH_LOG_HOST" envDefault:"localhost:7113"`
|
||||
}
|
||||
|
||||
func LoadConfig() (*Config, error) {
|
||||
@ -37,3 +35,5 @@ func LoadConfig() (*Config, error) {
|
||||
}
|
||||
return &config, nil
|
||||
}
|
||||
|
||||
const ModuleLogger = "answerer"
|
||||
|
@ -13,7 +13,7 @@ type DALs struct {
|
||||
}
|
||||
|
||||
func NewDALs(ctx context.Context, cfg Config, minioClient *minio.Client) (*DALs, error) {
|
||||
pgDAL, err := dal.New(ctx, cfg.PostgresCredentials, minioClient)
|
||||
pgDAL, err := dal.New(ctx, cfg.PostgresURL, minioClient)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import (
|
||||
)
|
||||
|
||||
func NewMinio(cfg Config) (*minio.Client, error) {
|
||||
minioClient, err := minio.New(cfg.MinioEP, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(cfg.MinioAK, cfg.MinioSK, ""),
|
||||
minioClient, err := minio.New(cfg.S3Endpoint, &minio.Options{
|
||||
Creds: credentials.NewStaticV4(cfg.S3AccessKey, cfg.S3SecretKey, ""),
|
||||
Secure: cfg.IsProd,
|
||||
})
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user