updated
This commit is contained in:
parent
c312cb79ba
commit
9eccbb71f4
6
.env
6
.env
@ -1,6 +1,6 @@
|
|||||||
#Configuración de la base de datos
|
#Configuración de la base de datos
|
||||||
DB_HOST=localhost
|
DB_HOST=db
|
||||||
DB_PORT=5434
|
DB_PORT=5432
|
||||||
DB_USER=admin
|
DB_USER=admin
|
||||||
DB_PASSWORD=admin
|
DB_PASSWORD=admin
|
||||||
DB_NAME=gotestdb
|
DB_NAME=gotestdb
|
||||||
@ -8,7 +8,7 @@ DB_MAX_OPEN_CONNS=25
|
|||||||
DB_MAX_IDLE_CONNS=10
|
DB_MAX_IDLE_CONNS=10
|
||||||
DB_CONN_MAX_LIFETIME=30m
|
DB_CONN_MAX_LIFETIME=30m
|
||||||
#Redis
|
#Redis
|
||||||
REDIS_HOST=localhost
|
REDIS_HOST=redis
|
||||||
REDIS_PORT=6379
|
REDIS_PORT=6379
|
||||||
REDIS_PASSWORD=TuPasswordSegura123
|
REDIS_PASSWORD=TuPasswordSegura123
|
||||||
REDIS_DB=0
|
REDIS_DB=0
|
||||||
|
|||||||
26
docker-compose.yml
Normal file
26
docker-compose.yml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
services:
|
||||||
|
syncronizador:
|
||||||
|
container_name: rendicion_gasto_syncronizador
|
||||||
|
environment:
|
||||||
|
- TZ=America/La_Paz
|
||||||
|
- LANG=es_BO.UTF-8
|
||||||
|
- LC_ALL=es_BO.UTF-8
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
restart: always
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- ./logs:/app/logs
|
||||||
|
networks:
|
||||||
|
- network_emba
|
||||||
|
logging:
|
||||||
|
driver: "json-file"
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "3"
|
||||||
|
compress: "true"
|
||||||
|
networks:
|
||||||
|
network_emba:
|
||||||
|
external: true
|
||||||
@ -81,7 +81,7 @@ func InitLogger(cfg *Config) {
|
|||||||
|
|
||||||
//elastic
|
//elastic
|
||||||
if cfg.ElasticEnabled {
|
if cfg.ElasticEnabled {
|
||||||
Log.Debug("✅ Elasticsearch enabled")
|
Log.Info("✅ Elasticsearch enabled")
|
||||||
es, err := elasticsearch.NewClient(elasticsearch.Config{
|
es, err := elasticsearch.NewClient(elasticsearch.Config{
|
||||||
Addresses: []string{cfg.ElasticURL},
|
Addresses: []string{cfg.ElasticURL},
|
||||||
})
|
})
|
||||||
|
|||||||
@ -64,7 +64,7 @@ func (g *GormDatabase) SyncRows(persistencia dto.Persistencia, rawData *[]map[st
|
|||||||
|
|
||||||
// Procesar lote
|
// Procesar lote
|
||||||
if len(batch) == batchSize || i == len(*rawData)-1 {
|
if len(batch) == batchSize || i == len(*rawData)-1 {
|
||||||
config.Log.Debugf(logPrefix+" Procesando batch de %d registros", len(batch))
|
config.Log.Info(logPrefix+" Procesando batch de %d registros", len(batch))
|
||||||
|
|
||||||
if len(persistencia.UpdateBy) > 0 {
|
if len(persistencia.UpdateBy) > 0 {
|
||||||
// Updates con múltiples campos
|
// Updates con múltiples campos
|
||||||
@ -173,12 +173,12 @@ func (g *GormDatabase) GetCredencialesFromTemplate(whereTemplate string, variabl
|
|||||||
query := whereTemplate
|
query := whereTemplate
|
||||||
var args []interface{}
|
var args []interface{}
|
||||||
|
|
||||||
config.Log.Debugf("🔎 Variables recibidas:")
|
config.Log.Info("🔎 Variables recibidas:")
|
||||||
for k, v := range variables {
|
for k, v := range variables {
|
||||||
placeholder := "@" + k
|
placeholder := "@" + k
|
||||||
query = strings.ReplaceAll(query, placeholder, "?")
|
query = strings.ReplaceAll(query, placeholder, "?")
|
||||||
args = append(args, v)
|
args = append(args, v)
|
||||||
config.Log.Debugf(" %s = %v", k, v)
|
config.Log.Infof(" %s = %v", k, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
config.Log.Debugf("📝 Consulta final construida:")
|
config.Log.Debugf("📝 Consulta final construida:")
|
||||||
|
|||||||
@ -155,13 +155,13 @@ func prepareAuthBody(auth dto.ServiceConfig, cred *model.CredencialesSAP, logPre
|
|||||||
}
|
}
|
||||||
|
|
||||||
if auth.GQL {
|
if auth.GQL {
|
||||||
config.Log.Debugf("%v 🧠 Preparando auth para GraphQL", logPrefix)
|
config.Log.Infof("%v 🧠 Preparando auth para GraphQL", logPrefix)
|
||||||
auth.Rest.Body = map[string]string{
|
auth.Rest.Body = map[string]string{
|
||||||
"username": cred.UserName,
|
"username": cred.UserName,
|
||||||
"password": cred.Password,
|
"password": cred.Password,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
config.Log.Debugf("%v🧠 Preparando auth para REST", logPrefix)
|
config.Log.Infof("%v🧠 Preparando auth para REST", logPrefix)
|
||||||
auth.Rest.Body = map[string]string{
|
auth.Rest.Body = map[string]string{
|
||||||
"CompanyDB": cred.CompanyDB,
|
"CompanyDB": cred.CompanyDB,
|
||||||
"UserName": cred.UserName,
|
"UserName": cred.UserName,
|
||||||
|
|||||||
@ -17,7 +17,7 @@ func CargarDesdeRedis[T any](cfg ports.RedisConfigProvider, clave string) (*T, e
|
|||||||
return nil, fmt.Errorf("error al obtener clave [%s] de redis: %w", clave, err)
|
return nil, fmt.Errorf("error al obtener clave [%s] de redis: %w", clave, err)
|
||||||
|
|
||||||
}
|
}
|
||||||
config.Log.Debugf("🔑 Clave [%s] obtenida de Redis: %s", clave, data)
|
config.Log.Infof("🔑 Clave [%s] obtenida de Redis: %s", clave, data)
|
||||||
var result T
|
var result T
|
||||||
if err := json.Unmarshal([]byte(data), &result); err != nil {
|
if err := json.Unmarshal([]byte(data), &result); err != nil {
|
||||||
config.Log.Errorf("❌ error al parsear JSON [%s]: %s", clave, err)
|
config.Log.Errorf("❌ error al parsear JSON [%s]: %s", clave, err)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user