Durable staging handoff, transactional outbox, at-least-once worker with lease fencing, idempotent versioned pipeline, three variants, operator tooling, contract tests and evidence. Includes the review fixes: reprocess source selection and failure settlement, replay guards, stale-job retirement, PNG structural/raster validation, migration rollback safety and audit events.
160 lines
5.4 KiB
Bash
160 lines
5.4 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.5.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
|
||
|
||
# --- Lab5: durable queues and async image processing -------------------------
|
||
# Synthetic broker credentials for the local Compose stand. The relay/worker
|
||
# connect inside the compose network; the management UI is published only on
|
||
# loopback by compose.yaml.
|
||
BROKER_USER=messenger
|
||
BROKER_PASSWORD=messenger
|
||
BROKER_VHOST=messenger
|
||
BROKER_URL=amqp://messenger:messenger@broker:5672/messenger
|
||
BROKER_EXCHANGE=attachments.jobs
|
||
BROKER_QUEUE=attachment.process.v1
|
||
BROKER_DLX=attachments.dlx
|
||
BROKER_DLQ=attachment.process.dead
|
||
BROKER_MANAGEMENT_PORT=15672
|
||
BROKER_CPU_LIMIT=0.50
|
||
BROKER_MEM_LIMIT=384M
|
||
|
||
# Worker process bounds. Concurrency=1 is the safe default for a 40 MP image on
|
||
# the course VM; raise it together with WORKER_MEM_LIMIT.
|
||
WORKER_CONCURRENCY=1
|
||
WORKER_PREFETCH=1
|
||
WORKER_CPU_LIMIT=1.00
|
||
WORKER_MEM_LIMIT=1G
|
||
WORKER_SHUTDOWN_TIMEOUT=30s
|
||
WORKER_HEALTH_PORT=8081
|
||
|
||
# Shared job contract. The API chooses the pipeline version for new uploads.
|
||
PROCESSING_PIPELINE_VERSION=1
|
||
PROCESSING_MAX_ATTEMPTS=5
|
||
PROCESSING_JOB_TIMEOUT=120s
|
||
PROCESSING_LEASE_TTL=180s
|
||
PROCESSING_HEARTBEAT=30s
|
||
PROCESSING_RETRY_BASE=2s
|
||
PROCESSING_RETRY_CAP=60s
|
||
|
||
# Outbox relay and lease reaper.
|
||
OUTBOX_POLL_INTERVAL=1s
|
||
OUTBOX_CLAIM_TTL=30s
|
||
OUTBOX_BATCH=20
|
||
OUTBOX_REAPER_INTERVAL=15s
|
||
OUTBOX_RECONCILE_AFTER=5m
|
||
OUTBOX_RETENTION=168h
|
||
RELAY_CPU_LIMIT=0.25
|
||
RELAY_MEM_LIMIT=128M
|
||
RELAY_HEALTH_PORT=8082
|
||
|
||
# Staging cleanup and admission control.
|
||
STAGING_ORPHAN_GRACE=1h
|
||
STAGING_FAILED_RETENTION=168h
|
||
ADMISSION_MAX_PENDING_PER_USER=20
|
||
ADMISSION_MAX_PENDING=200
|
||
ADMISSION_MAX_STAGED_BYTES=2147483648
|
||
ADMISSION_MAX_CONCURRENT_UPLOADS=8
|