Files
dance-lessons-coach/config.yaml
Gabriel Radureau 91d50e60ee feat(cache): add in-memory cache service (ADR-0022 Phase 1 part 2)
Implements Phase 1 part 2 of ADR-0022 (Rate Limiting and Cache Strategy):
in-memory cache service using github.com/patrickmn/go-cache. Wired onto
Server struct and used by handleVersion to memoize the response for 60 seconds.

Companion to PR #22 (per-IP rate limit middleware).

Changes:
- New: pkg/cache/cache.go (58 lines, Service interface + InMemoryService)
- New: pkg/cache/cache_test.go (125 lines, 6 unit tests, all passing)
- Modified: pkg/config/config.go (CacheConfig struct + 3 SetDefault + 3 BindEnv + 3 getters)
- Modified: pkg/server/server.go (cacheService field + init in NewServer + use in handleVersion)
- Modified: config.yaml (cache section with defaults)
- go.mod / go.sum (github.com/patrickmn/go-cache v2.1.0+incompatible)

Closes #13 (Phase 1 fully complete: rate limit in PR #22, cache here).
Phase 2 (Redis-compatible shared cache via Dragonfly/KeyDB) deferred.

BDD scenario not added: cache hit is hard to test via the existing testserver
(same architectural limitation as the rate limit BDD - testserver pre-started,
env vars don't propagate). Behavior is fully covered by unit tests (6/6 PASS).
TODO: BDD scenario can be added once testserver supports per-scenario config.

Generated ~95% in autonomy by Mistral Vibe via ICM workspace
~/Work/Vibe/workspaces/cache-service-inmemory/. T6 cost €2.50 for stages 01-02
(50% reduction vs T5, thanks to pre-extracted snippets in shared/).
Trainer (Claude) finalized commit/PR (Mistral hit max-turns).

🤖 Co-Authored-By: Mistral Vibe (devstral-2 / mistral-medium-3.5)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 13:23:58 +02:00

101 lines
2.9 KiB
YAML

# dance-lessons-coach Configuration
# This file serves as both the default configuration and documentation
# All available options are shown with their default values
# Server configuration
server:
# Host address to bind to (default: "0.0.0.0")
host: "0.0.0.0"
# Port to listen on (default: 8080)
port: 8080
# Shutdown configuration
shutdown:
# Timeout duration for graceful shutdown (default: 30s)
# Format: number + unit (s, m, h)
timeout: 30s
# Logging configuration
logging:
# Enable JSON output for structured logging (default: false)
# When true, logs are output in JSON format instead of console format
json: false
# Log level (default: "trace")
# Options: "trace", "debug", "info", "warn", "error", "fatal", "panic"
level: trace
# Log output file path (default: "" for stderr)
# If empty, logs will be written to stderr
# If specified, logs will be written to the specified file
# Example: "server.log" or "/var/log/dance-lessons-coach.log"
output: ""
# Telemetry configuration (OpenTelemetry)
telemetry:
# Enable OpenTelemetry tracing (default: false)
enabled: false
# OTLP endpoint for trace export (default: "localhost:4317")
# Format: host:port
otlp_endpoint: "localhost:4317"
# Service name for tracing (default: "dance-lessons-coach")
service_name: "dance-lessons-coach"
# Use insecure connection (no TLS) (default: true)
insecure: true
# Sampler configuration
sampler:
# Sampler type (default: "parentbased_always_on")
# Options: "always_on", "always_off", "traceidratio", "parentbased_always_on", "parentbased_always_off", "parentbased_traceidratio"
type: "parentbased_always_on"
# Sampling ratio (0.0 to 1.0, default: 1.0)
# Only used with traceidratio and parentbased_traceidratio samplers
ratio: 1.0
# Database configuration (PostgreSQL)
database:
# PostgreSQL host address (default: "localhost")
host: "localhost"
# PostgreSQL port (default: 5432)
port: 5432
# PostgreSQL username (default: "postgres")
user: "postgres"
# PostgreSQL password (default: "postgres")
# Change this for production!
password: "postgres"
# Database name (default: "dance_lessons_coach")
name: "dance_lessons_coach"
# SSL mode (default: "disable")
# Options: "disable", "allow", "prefer", "require", "verify-ca", "verify-full"
ssl_mode: "disable"
# Maximum number of open connections (default: 25)
max_open_conns: 25
# Maximum number of idle connections (default: 5)
max_idle_conns: 5
# Maximum lifetime of connections (default: "1h")
# Format: number + unit (s, m, h)
conn_max_lifetime: 1h
# Cache configuration (in-memory)
cache:
# Enable in-memory cache (default: true)
enabled: true
# Default TTL in seconds for cache items (default: 300 = 5 minutes)
default_ttl_seconds: 300
# Cleanup interval in seconds for expired items (default: 600 = 10 minutes)
cleanup_interval_seconds: 600