2d5b5834ec4d43ab1e7844f47f0f0f07d50aa8af
Implements the first phase of ADR-0023 selective hot-reloading. Adds viper.WatchConfig wiring + an OnConfigChange handler that re-unmarshals the Config struct on file changes and applies the hot-reloadable subset. Phase 1 reloadable field: logging.level — re-applied via SetupLogging on every change. The remaining 3 fields listed in ADR-0023 (api.v2_enabled, telemetry sampler type/ratio, auth.jwt.ttl) follow the same pattern and will land in subsequent phase PRs without further infrastructure work. Changes: - pkg/config/config.go : Config struct gets unexported viper + reloadMu fields; new WatchAndApply(ctx) method starts the watcher and stops it on context cancel. Defensive: no-op when no config file is in use. - pkg/server/server.go Run() : calls WatchAndApply(rootCtx) so the watcher stops on graceful shutdown. - pkg/config/config_hot_reload_test.go (new) : 3 unit tests covering end-to-end reload, no-config-file no-op, nil-viper no-op. Race detector clean. - adr/0023-config-hot-reloading.md : Status → Phase 1 Implemented; remaining fields explicitly Proposed for follow-up phases. Verifier verdict: APPROVE. Race detector passes. Full BDD suite still green. The @flaky scenario in features/config/config_hot_reloading.feature remains @flaky for now — activating it requires reliable cross-process file-watching behaviour which is sensitive to filesystem semantics on the CI runner; the unit test exercises the same code path deterministically.
dance-lessons-coach
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
Languages
Go
71.2%
Shell
21.7%
Gherkin
3.9%
TypeScript
1.4%
Vue
0.5%
Other
1.2%