Documentation
¶
Overview ¶
Example: Redis provider.
Models the runtime config of a checkout service: log level, request timeout, a rate limit, a maintenance feature flag, a database connection struct, and a list of allowed CORS origins. The Redis provider watches every key under "checkout/" with a single keyspace-notification subscription, so updates arrive as events rather than by polling.
Run it end to end:
docker compose up -d
docker compose exec redis redis-cli SET checkout/log_level info
docker compose exec redis redis-cli SET checkout/request_timeout 30s
docker compose exec redis redis-cli SET checkout/rate_limit_rps 100
docker compose exec redis redis-cli SET checkout/maintenance_mode false
docker compose exec redis redis-cli SET checkout/database '{"host":"db.internal","port":5432,"max_open_conns":20}'
docker compose exec redis redis-cli SET checkout/allowed_origins '["https://app.example.com"]'
go run main.go
Then change a value and watch the app log the event:
docker compose exec redis redis-cli SET checkout/rate_limit_rps 500 docker compose exec redis redis-cli SET checkout/maintenance_mode true
Click to show internal directories.
Click to hide internal directories.