optimize cfg
This commit is contained in:
parent
ed22813e11
commit
8d6a2c34d9
@ -90,15 +90,15 @@ func New(ctx context.Context, cfg initialize.Config, build Build) error {
|
||||
mailSender := senders2.NewMailLeadSender(clients.MailClient)
|
||||
leadSenders := []senders2.LeadSender{mailSender /* , tgSender */}
|
||||
|
||||
pgdal, err := dal.New(ctx, cfg.PostgresCredentials, minioClient)
|
||||
pgdal, err := dal.New(ctx, cfg.PostgresURL, minioClient)
|
||||
if err != nil {
|
||||
zapLogger.Error("failed init postgres", zap.Error(err))
|
||||
return err
|
||||
}
|
||||
|
||||
kafkaWorker, err := privilegewc2.NewKafkaConsumerWorker(privilegewc2.Config{
|
||||
KafkaBroker: cfg.KafkaBroker,
|
||||
KafkaTopic: cfg.KafkaTopic,
|
||||
KafkaBroker: cfg.KafkaBrokers,
|
||||
KafkaTopic: cfg.KafkaTopicTariff,
|
||||
ServiceKey: cfg.ServiceName,
|
||||
TickerInterval: time.Second * 10,
|
||||
ErrChan: errChan,
|
||||
|
@ -14,15 +14,13 @@ type Clients struct {
|
||||
func NewClients(cfg Config, logger *zap.Logger) *Clients {
|
||||
return &Clients{
|
||||
MailClient: clients.NewSmtpClient(clients.Deps{
|
||||
SmtpHost: cfg.SmtpHost,
|
||||
SmtpPort: cfg.SmtpPort,
|
||||
SmtpSender: cfg.SmtpSender,
|
||||
ApiKey: cfg.SmtpApiKey,
|
||||
SmtpApiUrl: cfg.SmtpApiUrl,
|
||||
SmtpSender: cfg.Sender,
|
||||
ApiKey: cfg.ApiKey,
|
||||
SmtpApiUrl: cfg.ApiUrl,
|
||||
}),
|
||||
CustomerClient: customer_clients.NewCustomersClient(customer_clients.CustomersClientDeps{
|
||||
Logger: logger,
|
||||
CustomerServiceHost: cfg.CustomerServiceAddress,
|
||||
CustomerServiceHost: cfg.CustomerMicroserviceRPCURL,
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
@ -8,26 +8,22 @@ import (
|
||||
|
||||
type Config struct {
|
||||
ServiceName string `env:"SERVICE_NAME" envDefault:"squiz"`
|
||||
KafkaBroker string `env:"KAFKA_BROKER" envDefault:"localhost:6379"`
|
||||
KafkaTopic string `env:"KAFKA_TOPIC" envDefault:"test-topic"`
|
||||
KafkaBrokers string `env:"KAFKA_BROKERS" envDefault:"localhost:6379"`
|
||||
KafkaTopicTariff string `env:"KAFKA_TOPIC_TARIFF" envDefault:"test-topic"`
|
||||
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"`
|
||||
PostgresCredentials string `env:"PG_CRED" envDefault:"host=localhost port=35432 user=squiz password=Redalert2 dbname=squiz sslmode=disable"`
|
||||
RedisHost string `env:"REDIS_HOST" envDefault:"localhost:6379"`
|
||||
RedisPassword string `env:"REDIS_PASSWORD" envDefault:"admin"`
|
||||
RedisDB uint64 `env:"REDIS_DB" envDefault:"2"`
|
||||
SmtpHost string `env:"SMTP_HOST" envDefault:"connect.mailclient.bz"`
|
||||
SmtpPort string `env:"SMTP_PORT" envDefault:"587"`
|
||||
SmtpSender string `env:"SMTP_SENDER" envDefault:"noreply@mailing.pena.digital"`
|
||||
SmtpUsername string `env:"SMTP_USERNAME" envDefault:"kotilion.95@gmail.com"`
|
||||
SmtpPassword string `env:"SMTP_PASSWORD" envDefault:"vWwbCSg4bf0p"`
|
||||
SmtpApiKey string `env:"SMTP_API_KEY" envDefault:"P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev"`
|
||||
SmtpApiUrl string `env:"SMTP_API_URL" envDefault:"https://api.smtp.bz/v1/smtp/send"`
|
||||
CustomerServiceAddress string `env:"CUSTOMER_SERVICE_ADDRESS" envDefault:"localhost:9001"`
|
||||
TgToken string `env:"TG_TOKEN"`
|
||||
S3Endpoint string `env:"S3_ENDPOINT" envDefault:"localhost:3002"`
|
||||
S3AccessKey string `env:"S3_ACCESS_KEY" envDefault:"minio"`
|
||||
S3SecretKey string `env:"S3_SECRET_KEY" envDefault:"miniostorage"`
|
||||
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"`
|
||||
Sender string `env:"MAIL_SENDER" envDefault:"noreply@mailing.pena.digital"`
|
||||
ApiKey string `env:"MAIL_API_KEY" envDefault:"P0YsjUB137upXrr1NiJefHmXVKW1hmBWlpev"`
|
||||
ApiUrl string `env:"API_URL" envDefault:"https://api.smtp.bz/v1/smtp/send"`
|
||||
CustomerMicroserviceRPCURL string `env:"CUSTOMER_MICROSERVICE_RPC_URL" envDefault:"localhost:9001"`
|
||||
TelegramToken string `env:"TELEGRAM_TOKEN"`
|
||||
}
|
||||
|
||||
func LoadConfig() (*Config, error) {
|
||||
|
@ -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