5 releases
0.1.4 | Jul 21, 2024 |
---|---|
0.1.3 | Jul 21, 2024 |
0.1.2 | Apr 19, 2024 |
0.1.1 | Apr 18, 2024 |
0.1.0 | Apr 18, 2024 |
#462 in Configuration
18KB
202 lines
Storus
A library that simplifies the life of rust developers by abstracting the low level communication protocols (REST/gRPC) when they want to use StooKV as their configurations management tool.
Usage
To use storus
, include the dependency in your Cargo.toml
as :
[dependencies]
storus = "0.1.4"
Next, add this to your crate:
use storus::stoo::Stoo;
use storus::stoo_config::StooConfig;
fn main() {
// ...
}
Examples
Create stoo client from minimal configurations:
use storus::stoo::Stoo;
use storus::stoo_config::StooConfig;
#[tokio::main]
async fn main() {
let config = StooConfig::from("http://localhost:50051");
let mut stookv = Stoo::new(config).await;
}
Create stoo client from extended configurations:
use crate::stoo::Stoo;
use crate::stoo_config::StooConfig;
#[tokio::main]
async fn main() {
let config = StooConfig::from("https://localhost:50051")
.response_timeout(Duration::from_millis(20000))
.connect_timeout(Duration::from_millis(1000))
.default_namespace("my-app")
.default_profile("prod")
.ca_certificate("/tmp/ca_cert.pem")
.domain("x.test.example.com");
let mut stookv = Stoo::new(config).await;
}
Complete example:
use storus::stoo::Stoo;
use storus::stoo_config::StooConfig;
#[tokio::main]
async fn main() {
let config = StooConfig::from("http://localhost:50051");
let mut stookv = Stoo::new(config).await;
//set value to a key
let result1 = stookv.set("my-app", "prod", "database.username", "admin3").await.unwrap();
println!("result1: {}", result1);
//get value from key
let result2 = stookv.get("my-app", "prod", "database.username").await.unwrap();
println!("result2: {}", result2);
//get all key value pairs by from a given namespace and profile
let result3 = stookv.get_all_by_namespace_and_profile("my-app", "prod").await.unwrap();
println!("result3: {:?}", result3);
//get a value from default namespace and profile as initially specified
let result4 = stookv.get_default("database.username").await.unwrap();
println!("result4: {}", result4);
//set secret key
let result5 = stookv.set_secret("my-app", "prod", "database.password", "qwerty@1234").await.unwrap();
println!("result5: {}", result5);
}
License
The project is licensed under MIT license.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in Storus
by you, shall be licensed as MIT, without any additional
terms or conditions.
Dependencies
~45MB
~807K SLoC