diff --git a/Dockerfile b/Dockerfile index fd88c45..288dcbd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ FROM golang:1.24 RUN mkdir /app ADD . /app/ WORKDIR /app -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server . +RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o server main.go # Second Stage FROM alpine diff --git a/controllers/deliveryController.go b/controllers/deliveryController.go index ab7b82e..d059919 100644 --- a/controllers/deliveryController.go +++ b/controllers/deliveryController.go @@ -709,7 +709,7 @@ func GetDeliverySummary(c *fiber.Ctx) error { `) if appuid != 0 { - qb.WriteString(" AND g.userid = ?") + qb.WriteString(" AND a.userid = ?") params = append(params, appuid) } diff --git a/db/connect.go b/db/connect.go index f90a871..b491b7e 100644 --- a/db/connect.go +++ b/db/connect.go @@ -183,18 +183,23 @@ func InitRedis() { DB: 0, // ✅ TIMEOUTS (VERY IMPORTANT) - DialTimeout: 10 * time.Second, - ReadTimeout: 10 * time.Second, - WriteTimeout: 10 * time.Second, + // Kept short so a slow/degraded Redis fails fast instead of tying up a + // pooled connection for tens of seconds. A previous config (10s x3 retries) + // let a single stuck call hold a connection for ~35s, which under concurrent + // load exhausted the pool and cascaded into a cluster-wide outage. + DialTimeout: 5 * time.Second, + ReadTimeout: 3 * time.Second, + WriteTimeout: 3 * time.Second, // ✅ POOL PoolSize: 50, MinIdleConns: 10, + PoolTimeout: 4 * time.Second, // ✅ RETRIES - MaxRetries: 3, - MinRetryBackoff: 500 * time.Millisecond, - MaxRetryBackoff: 2 * time.Second, + MaxRetries: 1, + MinRetryBackoff: 100 * time.Millisecond, + MaxRetryBackoff: 500 * time.Millisecond, }) maxRetries := 5 diff --git a/domain/delivery.go b/domain/delivery.go index 64f4368..79c4c8e 100644 --- a/domain/delivery.go +++ b/domain/delivery.go @@ -792,7 +792,7 @@ func GetUserDeliveriesv1(input models.DeliveryQuery) []models.Deliveryinfo { func GetAppUserDeliveries(input models.DeliveryQuery) []models.Deliveryinfo { var data []models.Deliveryinfo - logInfo("App User Deliveries", "appuserid", input.UserID) + logInfo("App User Deliveries", "appuserid", input.Appuserid) var ( q1 strings.Builder @@ -805,10 +805,10 @@ func GetAppUserDeliveries(input models.DeliveryQuery) []models.Deliveryinfo { q1.WriteString(deliveries) q1.WriteString(" WHERE b.moduleid = 6 AND g.status = 'Active' ") - // 🔹 Apply userid filter ONLY if userid > 0 - if input.UserID > 0 { - q1.WriteString(" AND g.userid = ? ") - params = append(params, input.UserID) + // 🔹 Apply appuserid filter ONLY if appuserid > 0 + if input.Appuserid > 0 { + q1.WriteString(" AND a.userid = ? ") + params = append(params, input.Appuserid) } // 🔹 Status filter (IGNORE if status = all)