client only.Expand description
Reading configuration from a config server.
The other half of this crate, behind the client feature: a
RemoteSource that fetches GET /{application}/{profile} and hands the
document to the engine, exactly as an etcd or a Vault source does. The two
halves live in one crate so that they are tested against each other —
every test in tests/client.rs drives this against the real router rather
than against a fixture of what the router is believed to return.
use std::time::Duration;
use dynamic_config_server::client::ConfigServer;
let source = ConfigServer::new("https://config.internal", "billing", "prod")
.with_token(std::env::var("CONFIG_TOKEN").unwrap_or_default())
.with_timeout(Duration::from_secs(5));§Watching
It subscribes. GET /{application}/{profile}/stream carries a generation
number, and ConfigServer::watch follows it: connect, read events,
re-fetch the document when the number moves, reconnect with the
Last-Event-ID the server left off at. The reconnect is a comparison
rather than a replay — a generation subsumes every one before it — so
there is no window in which a change can be missed by being reconnected
past.
§What it does not do
It does not verify provenance. The document arrives as JSON with no signature, so a client trusts the server exactly as far as TLS and the bearer token take it. A deployment that needs more should read from the store the server reads from.
Structs§
- Config
Server - A
RemoteSourcereading one application-and-profile from a config server.