Documentation
¶
Overview ¶
Example: PostgreSQL provider
Prerequisites:
- Start PostgreSQL: docker run -d --name postgres -p 5432:5432 -e POSTGRES_PASSWORD=root -e POSTGRES_DB=configdb postgres:16
- Create the config table and seed data: docker exec -i postgres psql -U postgres -d 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/postgresql/main.go
- In another terminal, update a value: docker exec -i postgres psql -U postgres -d configdb -c "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.