mysql

command
v0.2.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 12, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Example: MySQL 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 MySQL provider fetches every key under "checkout/" with a single batched query per poll cycle. Struct and array values are stored as JSON in the value column.

Run it end to end:

docker compose up -d
# wait a few seconds for MariaDB to accept connections, then seed:
docker compose exec -T mysql mariadb -uroot -proot configdb <<'SQL'
CREATE TABLE IF NOT EXISTS config (config_key VARCHAR(255) PRIMARY KEY, config_value TEXT);
REPLACE INTO config VALUES
  ('checkout/log_level', 'info'),
  ('checkout/request_timeout', '30s'),
  ('checkout/rate_limit_rps', '100'),
  ('checkout/maintenance_mode', 'false'),
  ('checkout/database', '{"host":"db.internal","port":5432,"max_open_conns":20}'),
  ('checkout/allowed_origins', '["https://app.example.com"]');
SQL
go run main.go

Then change a value and watch the app log the event:

docker compose exec -T mysql mariadb -uroot -proot configdb \
  -e "UPDATE config SET config_value='500' WHERE config_key='checkout/rate_limit_rps'"

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL