-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
873 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
pub use self::strategy::Strategy; | ||
|
||
#[derive(Clone, Copy, Debug)] | ||
pub enum Action { | ||
NoOp, | ||
Panic, | ||
} | ||
|
||
pub mod strategy { | ||
use super::Action; | ||
|
||
pub trait Strategy { | ||
fn decide(&self, res: &prometheus::Error) -> Action; | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, Default)] | ||
pub struct NoOp; | ||
|
||
impl Strategy for NoOp { | ||
fn decide(&self, _: &prometheus::Error) -> Action { | ||
Action::NoOp | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, Default)] | ||
pub struct Panic; | ||
|
||
impl Strategy for Panic { | ||
fn decide(&self, _: &prometheus::Error) -> Action { | ||
Action::Panic | ||
} | ||
} | ||
|
||
#[derive(Clone, Copy, Debug, Default)] | ||
pub struct PanicInDebugNoOpInRelease; | ||
|
||
impl Strategy for PanicInDebugNoOpInRelease { | ||
fn decide(&self, _: &prometheus::Error) -> Action { | ||
#[cfg(debug_assertions)] | ||
{ | ||
Action::Panic | ||
} | ||
#[cfg(not(debug_assertions))] | ||
{ | ||
Action::Panic | ||
} | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
pub fn add(left: usize, right: usize) -> usize { | ||
left + right | ||
} | ||
pub mod failure; | ||
pub mod metric; | ||
pub mod recorder; | ||
pub mod storage; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
use super::*; | ||
#[doc(inline)] | ||
pub use self::{metric::Metric, recorder::Recorder}; | ||
|
||
#[test] | ||
fn it_works() { | ||
let result = add(2, 2); | ||
assert_eq!(result, 4); | ||
} | ||
pub fn register() -> Result<Recorder, metrics::SetRecorderError> { | ||
Recorder::new().register() | ||
} |
Oops, something went wrong.