Features
- Support
toml,yaml,json configuration type.
- Dynamic configuration

Import
- Default with dynamic file configuration
[dependencies]
kosei = { version = "0.1" }
[dependencies]
kosei = { version = "0.1", features = ["apollo"] }
Quickstart
See examples for further use.
Config Entry
#[derive(Clone, Debug, Deserialize)]
struct Entry {
...
}
#[test]
fn base_test() {
let config: Config<Entry> = Config::from_file("config/config.yaml");
let entry: &Entry = config.as_inner(); let entry: Entry = config.to_inner(); let entry: Entry = config.into_inner(); }
#[tokio::test]
async fn dynamic_test() {
let (config, mut watcher) = DynamicConfig::<Entry>::watch_file("config/config.yaml");
watcher.watch().unwrap();
let lock = config.lock();
let entry: &Entry = lock.as_inner(); let entry: Entry = lock.to_inner(); let arc = config.as_arc(); watcher.stop().unwrap();
watcher.watch().unwrap();
}
#[tokio::test]
async fn apollo_test() {
let client = ApolloClient::new("http://localhost:8080")
.appid("114514")
.namespace("test", ConfigType::TOML);
let (config, mut watcher) =
DynamicConfig::<Entry>::watch_apollo(client, WatchMode::RealTime).await;
watcher.verbose();
watcher.watch().unwrap();
println!("{:?}", config);
watcher.stop().unwrap();
watcher.watch().unwrap();
do_somthing(config);
}