diff --git a/README.md b/README.md index bb5d6d15a82c21b635925def04432045db09eae4..6f02ec6a123c1e694db9212e47df8400fad9dccd 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,22 @@ # mquery (placeholder name) A Rust library for handling PROMQL (and possibly MetricsQL) queries. -# Usage Example +## Usage Example ```rust use mquery::{Auth, QueryManager}; -use tokio::runtime::Runtime; -dotenv::dotenv().expect("No .env file found in working dir"); -let url = std::env::var("VM_URL").expect("VM URL not found in env"); -let token = std::env::var("VM_TOKEN").expect("VM URL not found in env"); -let rt = Runtime::new().unwrap(); -let query = "total_http_requests"; -let _response = rt - .block_on( - QueryManager::new(url.parse().unwrap()) - .auth(Auth::Bearer(token)) - .query(query), - ) - .expect("operation failed"); +#[tokio::main] +async fn main() { + dotenv::dotenv().expect("No .env file found in working dir"); + let url = std::env::var("VM_URL").expect("VM URL not found in env"); + let token = std::env::var("VM_TOKEN").expect("VM URL not found in env"); + let query = "total_http_requests"; + + let _response = QueryManager::new(url.parse().unwrap()) + .auth(Auth::Bearer(token)) + .query(query) + .await + .expect("operation failed"); } ```