fix: review findings (async SQS dispatcher, backoff, batch insert, shutdown order, pagination, HMAC) + loadtest fixes; v0.1.6

This commit is contained in:
“Naeel”
2026-08-16 18:24:09 +04:00
parent 090cedca67
commit 3fedf9317c
27 changed files with 581 additions and 122 deletions
+11 -1
View File
@@ -4,6 +4,8 @@ import (
"context"
"database/sql"
"fmt"
"os"
"strconv"
"time"
)
@@ -39,7 +41,15 @@ func Open(ctx context.Context, dsn string) (*DeviceStore, error) {
if err != nil {
return nil, fmt.Errorf("store: open DB: %w", err)
}
db.SetMaxOpenConns(5)
// Пул устройств: дефолт 20 (ревью 2026-08-16: 5 мало для API+MQTT auth),
// переопределяется IOT_PG_MAX_CONNS.
maxConns := 20
if v := os.Getenv("IOT_PG_MAX_CONNS"); v != "" {
if n, convErr := strconv.Atoi(v); convErr == nil && n > 0 {
maxConns = n
}
}
db.SetMaxOpenConns(maxConns)
db.SetMaxIdleConns(2)
db.SetConnMaxLifetime(5 * time.Minute)