feat: add 5 experiment
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"embed"
|
||||
"errors"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -43,6 +44,13 @@ func OpenDatabase(ctx context.Context) (*pgxpool.Pool, error) {
|
||||
return nil, err
|
||||
}
|
||||
cfg.MaxConns = 10
|
||||
if value := os.Getenv("DATABASE_MAX_CONNS"); value != "" {
|
||||
maxConns, parseErr := strconv.Atoi(value)
|
||||
if parseErr != nil || maxConns < 1 || maxConns > 100 {
|
||||
return nil, errors.New("DATABASE_MAX_CONNS must be between 1 and 100")
|
||||
}
|
||||
cfg.MaxConns = int32(maxConns)
|
||||
}
|
||||
cfg.ConnConfig.ConnectTimeout = 5 * time.Second
|
||||
db, err := pgxpool.NewWithConfig(ctx, cfg)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user