Struct Client

Source
pub struct Client { /* private fields */ }
Expand description

The core of the kairosdb client, owns a HTTP connection.

Implementations§

Source§

impl Client

Source

pub fn new(host: &str, port: u32) -> Client

Constructs a new KairosDB Client

§Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);
Source

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"));
Source

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();
Source

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())
Source

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())
Source

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())
Source

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()));
Source

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());
Source

pub fn tagnames(&self) -> Result<Vec<String>, KairoError>

Returns a list of all tagnames

§Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);

let result = client.tagnames();
assert!(result.is_ok());
assert!(result.unwrap().contains(&"test".to_string()));
Source

pub fn tagvalues(&self) -> Result<Vec<String>, KairoError>

Returns a list of all tagvalues

§Example
use kairosdb::Client;
let client = Client::new("localhost", 8080);

let result = client.tagvalues();
assert!(result.is_ok());
assert!(result.unwrap().contains(&"first".to_string()));

Trait Implementations§

Source§

impl Debug for Client

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Err = <U as TryFrom<T>>::Err

Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Err>

Source§

impl<T> ErasedDestructor for T
where T: 'static,