Добавить X-Instance-Id, задержку drain при SIGTERM и отдельный запуск миграций

This commit is contained in:
2026-11-02 16:58:11 +03:00
parent 5b9f377783
commit 7fa8881eb3
21 changed files with 389 additions and 64 deletions
+5 -5
View File
@@ -1,8 +1,9 @@
// Package postgres opens the connection pool and applies the schema.
//
// Pool size and server-side timeouts are constants rather than settings: they
// bound how long one request can hold a connection, and the request deadline
// of the API is chosen against them.
// Server-side timeouts are constants rather than settings: they bound how
// long one request can hold a connection, and the request deadline of the API
// is chosen against them. The pool size is a setting, because the scaling
// study varies it.
package postgres
import (
@@ -27,7 +28,6 @@ import (
)
const (
maxConns = 10
connectTimeout = time.Second
statementTimeout = 5 * time.Second
idleInTxTimeout = 10 * time.Second
@@ -35,7 +35,7 @@ const (
const codeUniqueViolation = "23505"
func NewPool(ctx context.Context, dsn string) (*pgxpool.Pool, error) {
func NewPool(ctx context.Context, dsn string, maxConns int32) (*pgxpool.Pool, error) {
cfg, err := pgxpool.ParseConfig(dsn)
if err != nil {
return nil, fmt.Errorf("parse database url: %w", err)