Skip to content

Commit

Permalink
Skeletons for Drain and Error impls
Browse files Browse the repository at this point in the history
  • Loading branch information
56quarters committed Feb 13, 2017
1 parent aa51a3d commit 2f3a9ac
Showing 1 changed file with 53 additions and 3 deletions.
56 changes: 53 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,66 @@
extern crate cadence;
extern crate slog;

use std::error;
use std::fmt;
use std::sync::Arc;
use cadence::MetricClient;
use cadence::{MetricClient, MetricError};
use slog::{Drain, Record, OwnedKeyValueList};


///
///
///
#[derive(Clone)]
pub struct CadenceDrain {
client: Arc<MetricClient + Sync + Send>,
}

pub struct DrainBuilder<'a> {
prefix: &'a str,
impl CadenceDrain {
///
///
///
pub fn new<T>(client: T) -> CadenceDrain where T: MetricClient + Sync + Send + 'static {
CadenceDrain { client: Arc::new(client) }
}
}


impl Drain for CadenceDrain {
type Error = ::Error;

fn log(&self, info: &Record, _: &OwnedKeyValueList) -> Result<(), Error> {
Ok(())
}
}


///
///
///
#[derive(Debug)]
pub enum Error {
ClientError(MetricError),
}

impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
Error::ClientError(ref e) => e.fmt(f),
}
}
}

impl error::Error for Error {
fn cause(&self) -> Option<&error::Error> {
match *self {
Error::ClientError(ref e) => Some(e),
}
}

fn description(&self) -> &str {
match *self {
Error::ClientError(ref e) => e.description()
}
}
}

0 comments on commit 2f3a9ac

Please sign in to comment.