Expand description
AgileConfig client for the config crate.
This crate talks to an AgileConfig cluster over HTTP and WebSocket and exposes configuration through two types:
Clientloads published key/value items, optionally caches them on disk, and can keep a WebSocket session for live reload notifications.Sourceimplementsconfig::AsyncSourceso the snapshot can be composed with other sources (files, environment variables, and so on).
§Building a client
Construct ClientOptions directly or use Client::builder:
use agile_config_client::{Client, ClientOptions};
let from_struct = Client::new(ClientOptions {
app_id: "app".into(),
secret: "secret".into(),
nodes: vec!["http://localhost:5000".into()],
env: "DEV".into(),
..ClientOptions::default()
})?;
let from_builder = Client::builder()
.app_id("app")
.secret("secret")
.nodes(["http://localhost:5000"])
.env("DEV")
.build()?;§One-shot load with config
Source::collect (via Client::source) performs HTTP
(and cache fallback). It does not open a WebSocket.
use agile_config_client::{Client, ClientOptions};
let client = Client::new(ClientOptions {
app_id: "app".into(),
secret: "secret".into(),
nodes: vec!["http://localhost:5000".into()],
..ClientOptions::default()
})?;
let settings = config::Config::builder()
.add_async_source(client.source())
.build()
.await?;
let connection = settings.get_string("db.connection")?;Keys that the C# client exposes as group:key become dotted paths for the
config crate (db:connection → db.connection).
§Live updates
Call Client::connect to pull configuration and start WebSocket
reconnect/heartbeat. Keep the Client alive, then listen with
Client::subscribe. This crate never rebuilds config::Config for you.
use agile_config_client::{Client, ClientOptions};
let client = Client::new(ClientOptions {
app_id: "app".into(),
secret: "secret".into(),
nodes: vec!["http://localhost:5000".into()],
..ClientOptions::default()
})?;
client.connect().await?;
let mut rx = client.subscribe();
while rx.changed().await.is_ok() {
let snapshot = client.snapshot();
// Rebuild `config::Config` or swap application state here.
let _ = snapshot.get("db:connection");
}Lookups on ConfigSnapshot are case-sensitive.
§Features
| Feature | Default | Purpose |
|---|---|---|
cache-encrypt | off | AES-ECB encryption for the local cache file (C# compatible) |
Structs§
- Cache
Options - Local cache of the last successfully pulled configuration JSON.
- Client
- Client for an
AgileConfigcluster. - Client
Builder - Fluent builder for
Client/ClientOptions. - Client
Options - Connection and cache settings for
Client. - Config
Item - One published configuration item as returned by the HTTP API.
- Config
Snapshot - Point-in-time view of configuration pulled from
AgileConfig. - Source
- Read-only configuration source backed by a
crate::Client.
Enums§
- Error
- Failures that can occur while configuring, loading, or connecting.