feat(app) lab 3 implemented

This commit is contained in:
imadev
2026-10-30 18:11:30 +03:00
parent f731f9b460
commit 48a616e910
57 changed files with 1390 additions and 303 deletions
+5 -9
View File
@@ -2,10 +2,6 @@
// parameterized SQL, one bounded pool and explicit transaction boundaries.
// Contract errors are returned as common.AppError so HTTP status mapping stays
// in one place.
//
// AGENT: Persistence was split from one large file by aggregate (users, chats,
// messages). Queries, transaction boundaries and error mapping are unchanged;
// only file organization and scan helpers changed.
package store
import (
@@ -16,12 +12,13 @@ import (
)
type Store struct {
pool *pgxpool.Pool
timeout time.Duration
pool *pgxpool.Pool
timeout time.Duration
idempotencyTTL time.Duration
}
func New(pool *pgxpool.Pool, timeout time.Duration) *Store {
return &Store{pool: pool, timeout: timeout}
func New(pool *pgxpool.Pool, timeout, idempotencyTTL time.Duration) *Store {
return &Store{pool: pool, timeout: timeout, idempotencyTTL: idempotencyTTL}
}
func (s *Store) withTimeout(ctx context.Context) (context.Context, context.CancelFunc) {
@@ -34,7 +31,6 @@ func (s *Store) Ping(ctx context.Context) error {
return s.pool.Ping(pingCtx)
}
// rowScanner is the common subset of pgx.Row and pgx.Rows used by scan helpers.
type rowScanner interface {
Scan(dest ...any) error
}