-
-
Save zerosign/b70fdf85513c2b4aaad7 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub mod monitor { | |
enum Context { | |
Minimal(host: String, app: String, version: String), | |
Compact( | |
host: String, app: String, version: String, | |
namespace: String | |
) | |
} | |
enum Metric { | |
Histogram(u32), | |
Gauge(f32), | |
Counter(u32) | |
} | |
pub struct Data<T = Metric> { | |
context: Context, | |
time: u64, | |
metrics: Vec<T> | |
} | |
trait DataBuffer { | |
fn record(&self, metric: Metric); | |
} | |
trait Protocol { | |
fn send(&self, data: Data) -> Result<bool>; | |
fn send_many(&self, data: Buffer<Data>) -> Result<bool>; | |
} | |
struct GraphiteProtocol; | |
struct NewRelicProtocol; | |
struct CollectDProtocol; | |
struct FluentDProtocol; | |
impl Protocol for GraphiteProtocol { | |
} | |
impl Protocol for NewRelicProtocol { | |
} | |
impl Protocol for CollectDProtocol { | |
} | |
impl Protocol for FluentDProtocol { | |
} | |
pub struct Manager<Protocol> { | |
buffer: Map<Context, List<Metric>>, | |
protocol: Protocol | |
} | |
impl Manager { | |
fn new<Protocol>(protocol: Protocol) -> Manager<Protocol> { | |
Manager<Protocol> { | |
protocol: | |
} | |
} | |
} | |
impl Default for Manager { | |
fn default() -> Manager<CollectDProtocol> { | |
} | |
} | |
impl DataBuffer for Manager { | |
fn record(&self, context: Context, metric: Metric) { | |
} | |
} | |
static manager = Manager::new(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment