Skip to content

Instantly share code, notes, and snippets.

Created October 8, 2015 10:51
Show Gist options
  • Save anonymous/8e97f158da24033159b4 to your computer and use it in GitHub Desktop.
Save anonymous/8e97f158da24033159b4 to your computer and use it in GitHub Desktop.
Shared via Rust Playground
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