107 lines
3.9 KiB
Bash
107 lines
3.9 KiB
Bash
# Copy to .env for your LOCAL synthetic test environment; never commit .env.
|
||
# Values below are the variables this implementation actually reads
|
||
# (viper: section.name -> SECTION_NAME, see internal/config/config.go).
|
||
#
|
||
# Mapping to the logical names suggested by the skeleton:
|
||
# APP_HOST / APP_PORT -> SERVER_HOST / SERVER_PORT
|
||
# SESSION_STORE=postgres -> server-side sessions live in PostgreSQL (SESSION_TTL_SECONDS)
|
||
# DATABASE_URL_FILE -> unused: POSTGRES_* below pass no secret files
|
||
# CACHE_URL_FILE -> unused: REDIS_* below pass no secret files
|
||
# API_REPLICAS -> number of API replicas of the stand (compose.yaml)
|
||
#
|
||
# APP_ENV selects config/<env>/config.yaml; the implementation supports only `dev`.
|
||
APP_ENV=dev
|
||
|
||
SERVER_HOST=0.0.0.0
|
||
SERVER_PORT=8080
|
||
SERVER_READ_HEADER_TIMEOUT=10s
|
||
SERVER_READ_TIMEOUT=60s
|
||
SERVER_SHUTDOWN_TIMEOUT=10s
|
||
# Предел размера тела запроса (байт): защищает реплику от чтения огромного тела
|
||
# до валидации. Для вложений LAB4 (до 10 MiB) значение нужно поднять.
|
||
SERVER_MAX_BODY_BYTES=262144
|
||
|
||
LOG_LEVEL=info
|
||
LOG_FORMAT=json
|
||
|
||
# Synthetic credentials for the local stand only; override in .env for anything else.
|
||
POSTGRES_HOST=localhost
|
||
POSTGRES_PORT=5432
|
||
POSTGRES_DATABASE=messenger
|
||
POSTGRES_USER=messenger
|
||
POSTGRES_PASSWORD=messenger
|
||
POSTGRES_SSL_MODE=disable
|
||
POSTGRES_MAX_CONNS=10
|
||
POSTGRES_MIN_CONNS=1
|
||
POSTGRES_MAX_CONN_LIFETIME=1h
|
||
POSTGRES_MAX_CONN_IDLE_TIME=30m
|
||
POSTGRES_CONNECT_TIMEOUT=5s
|
||
POSTGRES_QUERY_TIMEOUT=5s
|
||
|
||
REDIS_ENABLED=true
|
||
REDIS_HOST=localhost
|
||
REDIS_PORT=6379
|
||
REDIS_PASSWORD=
|
||
REDIS_DB=0
|
||
# -1 disables go-redis retries; 0 keeps the library default (3 retries).
|
||
REDIS_MAX_RETRIES=-1
|
||
REDIS_DIAL_TIMEOUT=300ms
|
||
REDIS_READ_TIMEOUT=200ms
|
||
REDIS_WRITE_TIMEOUT=200ms
|
||
REDIS_POOL_SIZE=10
|
||
|
||
CACHE_ENABLED=true
|
||
CACHE_CHAT_LIST_TTL=5m
|
||
CACHE_LOCK_TTL=10s
|
||
CACHE_LOCK_WAIT_TIMEOUT=2s
|
||
|
||
SESSION_TTL_SECONDS=3600
|
||
|
||
# Retention of a message Idempotency-Key in the shared store; contract 1.3.0
|
||
# requires at least 24 h.
|
||
IDEMPOTENCY_TTL_SECONDS=86400
|
||
|
||
# Lab3 stand (compose.yaml): number of API replicas behind the LB and per-replica
|
||
# CPU/RAM limits. Track 1 varies them to compare 1/2/4 replicas at a fixed total
|
||
# budget, e.g. API_REPLICAS=4 API_CPU_LIMIT=0.25 API_MEM_LIMIT=192M.
|
||
API_REPLICAS=2
|
||
API_CPU_LIMIT=0.50
|
||
API_MEM_LIMIT=256M
|
||
|
||
# Connections of ONE API replica to PostgreSQL; the total is replicas × value.
|
||
# Track 1 checks whether the shared connection budget becomes the saturation
|
||
# point: at 4 replicas the default 10 means 40 connections against one database.
|
||
POSTGRES_MAX_CONNS=10
|
||
|
||
# CPU quota of the shared database. Track 1 shows it is the stand's saturation
|
||
# point: the API uses a fraction of its budget while PostgreSQL sits at its own.
|
||
POSTGRES_CPU_LIMIT=0.50
|
||
|
||
# Memory quota of the shared database. The track 1 series r/g/pool were measured
|
||
# with 512M, the db1cpu control — with 384M (see evidence/track1/profile-*.json).
|
||
POSTGRES_MEM_LIMIT=192M
|
||
|
||
# Loopback port of the HAProxy operator page (UP/DOWN of every replica).
|
||
LB_STATS_PORT=8404
|
||
|
||
# --- Lab4: private S3 object store (SeaweedFS) -------------------------------
|
||
# Synthetic local application credentials. infra/s3/s3.json must contain the
|
||
# same app values; scripts/check_s3_creds.py enforces that before the stand starts.
|
||
# Admin credentials live only in infra/s3/s3.json and s3-init defaults; never put
|
||
# them in .env, because the API service loads this file.
|
||
S3_ENDPOINT=http://localhost:8333
|
||
S3_PUBLIC_ENDPOINT=http://127.0.0.1:8333
|
||
S3_PORT=8333
|
||
S3_REGION=us-east-1
|
||
S3_BUCKET=messenger-attachments
|
||
S3_ACCESS_KEY_ID=lab4app
|
||
S3_SECRET_ACCESS_KEY=lab4app-secret
|
||
|
||
# Attachment limits from contract 1.4.0.
|
||
MAX_UPLOAD_BYTES=10485760
|
||
MAX_IMAGE_PIXELS=40000000
|
||
# Presigned upload lifetime and the sweeper's safety window.
|
||
S3_PRESIGN_TTL=5m
|
||
S3_SWEEP_INTERVAL=1m
|
||
S3_SWEEP_GRACE=10m
|