pub struct Client { /* private fields */ }
Expand description
The core of the kairosdb client, owns a HTTP connection.
Implementations§
Source§impl Client
impl Client
Sourcepub fn new(host: &str, port: u32) -> Client
pub fn new(host: &str, port: u32) -> Client
Constructs a new KairosDB Client
§Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);
Sourcepub fn version(&self) -> Result<String, KairoError>
pub fn version(&self) -> Result<String, KairoError>
Returns the version string of the KairosDB Server
§Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);
assert!(client.version().unwrap().starts_with("KairosDB"));
Sourcepub fn health(&self) -> Result<Vec<String>, KairoError>
pub fn health(&self) -> Result<Vec<String>, KairoError>
Returns the health status of the KairosDB Server
§Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);
let response = client.health();
Sourcepub fn add(&self, datapoints: &Datapoints) -> Result<(), KairoError>
pub fn add(&self, datapoints: &Datapoints) -> Result<(), KairoError>
Method to add datapoints to the time series database
§Example
use kairosdb::Client;
use kairosdb::datapoints::Datapoints;
let client = Client::new("localhost", 8080);
let mut datapoints = Datapoints::new("first", 0);
datapoints.add_ms(1475513259000, 11.0);
datapoints.add_ms(1475513259001, 12.0);
datapoints.add_tag("test", "first");
let result = client.add(&datapoints);
assert!(result.is_ok())
Sourcepub fn query(&self, query: &Query) -> Result<ResultMap, KairoError>
pub fn query(&self, query: &Query) -> Result<ResultMap, KairoError>
Runs a query on the database.
§Example
use kairosdb::Client;
use kairosdb::query::{Query, Time, TimeUnit};
let client = Client::new("localhost", 8080);
let query = Query::new(
Time::Nanoseconds(1),
Time::Relative{value: 1, unit: TimeUnit::WEEKS});
let result = client.query(&query);
assert!(result.is_ok())
Sourcepub fn delete(&self, query: &Query) -> Result<(), KairoError>
pub fn delete(&self, query: &Query) -> Result<(), KairoError>
Runs a delete query on the database. View the query structure to understand more about.
§Example
use kairosdb::Client;
use kairosdb::query::{Query, Time, TimeUnit};
let client = Client::new("localhost", 8080);
let query = Query::new(
Time::Nanoseconds(1),
Time::Relative{value: 1, unit: TimeUnit::WEEKS});
let result = client.delete(&query);
assert!(result.is_ok())
Sourcepub fn list_metrics(&self) -> Result<Vec<String>, KairoError>
pub fn list_metrics(&self) -> Result<Vec<String>, KairoError>
Returns a list with all metric names
§Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);
let result = client.list_metrics();
assert!(result.is_ok());
assert!(result.unwrap().contains(&"first".to_string()));
Sourcepub fn delete_metric(&self, metric: &str) -> Result<(), KairoError>
pub fn delete_metric(&self, metric: &str) -> Result<(), KairoError>
Deleting a metric
§Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);
let result = client.delete_metric(&"first");
assert!(result.is_ok());
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Client
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more