Documentation
¶
Overview ¶
Example: MySQL provider
Prerequisites:
- Start MySQL: docker run -d --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=configdb mysql:8
- Create the config table and seed data: docker exec -i mysql mysql -uroot -proot configdb <<'SQL' CREATE TABLE config ( config_key VARCHAR(255) PRIMARY KEY, config_value TEXT ); INSERT INTO config VALUES ('myapp/db/host', 'localhost'); INSERT INTO config VALUES ('myapp/db/port', '5432'); INSERT INTO config VALUES ('myapp/verbose', 'true'); INSERT INTO config VALUES ('myapp/timeout', '30s'); SQL
- Run: go run examples/mysql/main.go
- In another terminal, update a value: docker exec -i mysql mysql -uroot -proot configdb -e "UPDATE config SET config_value='3306' WHERE config_key='myapp/db/port'" Watch the output — the update is reflected within the poll interval.
Click to show internal directories.
Click to hide internal directories.