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

dance-lessons-coach

Build Status Go Report Card Version License BDD Coverage UNIT Coverage

Go web service demonstrating idiomatic package structure, versioned JSON API, and production-ready features.

Features

  • Versioned JSON API (/api/v1, /api/v2)
  • Chi router with graceful shutdown
  • Zerolog structured logging (console and JSON modes)
  • Viper configuration (file + env vars)
  • Readiness endpoint for Kubernetes / service mesh
  • OpenTelemetry / Jaeger distributed tracing
  • OpenAPI / Swagger UI (embedded in binary)
  • PostgreSQL user service with JWT auth
  • BDD + unit tests

Quick Start

git clone https://gitea.arcodange.lab/arcodange/dance-lessons-coach.git
cd dance-lessons-coach
./scripts/build.sh          # produces ./bin/server and ./bin/greet
./scripts/start-server.sh start
curl http://localhost:8080/api/health
curl http://localhost:8080/api/v1/greet/Alice

Stop: ./scripts/start-server.sh stop

Greet CLI

go run ./cmd/greet           # Hello world!
go run ./cmd/greet Alice     # Hello Alice!

Configuration

All options are available via config.yaml or DLC_* environment variables.

Env var Default Description
DLC_SERVER_PORT 8080 Listening port
DLC_SERVER_HOST 0.0.0.0 Bind address
DLC_LOGGING_JSON false JSON log format
DLC_LOGGING_OUTPUT stderr Log file path
DLC_SHUTDOWN_TIMEOUT 30s Graceful shutdown window
DLC_API_V2_ENABLED false Enable /api/v2 routes
DLC_CONFIG_FILE ./config.yaml Override config path

See config.example.yaml for a full template.

API

Method Path Description
GET /api/health Liveness check
GET /api/ready Readiness check (503 during shutdown)
GET /api/version Version info (?format=plain|full|json)
GET /api/v1/greet/ Default greeting
GET /api/v1/greet/{name} Named greeting
POST /api/v2/greet V2 greeting with validation
GET /swagger/ Swagger UI

Testing

go test ./...                          # unit + integration tests
./scripts/test-graceful-shutdown.sh    # lifecycle + JSON logging validation
./scripts/test-opentelemetry.sh        # tracing end-to-end

Gitea Client

AI agent helper script at .vibe/skills/gitea-client/scripts/gitea-client.sh.

Auth setup:

echo "your_token" > ~/.gitea_token
chmod 600 ~/.gitea_token
export GITEA_API_TOKEN_FILE="$HOME/.gitea_token"

Get a token at https://gitea.arcodange.lab → Profile → Settings → Applications.

Architecture

Key decisions are documented in adr/. See AGENTS.md for the full development reference (commands, config, ADR index, commit conventions).

License

MIT

Description
No description provided
Readme 57 MiB
Languages
Go 71.2%
Shell 21.7%
Gherkin 3.9%
TypeScript 1.4%
Vue 0.5%
Other 1.2%