pub struct Db { /* private fields */ }Expand description
An org’s check history.
Implementations§
Source§impl Db
impl Db
pub fn open(path: &Path) -> Result<Db>
pub fn memory() -> Result<Db>
pub fn insert(&self, monitor: &str, c: &Check) -> Result<()>
Sourcepub fn recent(&self, monitor: &str, limit: usize) -> Result<Vec<Check>>
pub fn recent(&self, monitor: &str, limit: usize) -> Result<Vec<Check>>
The newest checks first.
Sourcepub fn rollup(&mut self, now: u64) -> Result<()>
pub fn rollup(&mut self, now: u64) -> Result<()>
Roll every complete hour not rolled up yet into hourly, then drop
what is past its keep.
Sourcepub fn counts(&self, monitor: &str, from: u64, to: u64) -> Result<(u64, u64)>
pub fn counts(&self, monitor: &str, from: u64, to: u64) -> Result<(u64, u64)>
Checks and successes in [from, to): whole hours from the rollup,
the rest from the raw checks.
Sourcepub fn uptime(&self, monitor: &str, from: u64, to: u64) -> Result<Option<f64>>
pub fn uptime(&self, monitor: &str, from: u64, to: u64) -> Result<Option<f64>>
Percent up over [from, to); none without checks.
Sourcepub fn latency(
&self,
monitor: &str,
from: u64,
) -> Result<(Option<u64>, Option<u64>)>
pub fn latency( &self, monitor: &str, from: u64, ) -> Result<(Option<u64>, Option<u64>)>
Latency percentiles (p50, p95) of successful checks since from.
Sourcepub fn buckets(
&self,
monitor: &str,
from: u64,
to: u64,
step: u64,
) -> Result<Vec<Bucket>>
pub fn buckets( &self, monitor: &str, from: u64, to: u64, step: u64, ) -> Result<Vec<Bucket>>
Buckets of step over [from, to). Steps under an hour come from
the raw checks (the last 7 days); an hour or more from the rollup
(p50 and p95 then the median of the hours’).
Sourcepub fn open_incident(
&self,
monitor: &str,
started: u64,
error: Option<&str>,
) -> Result<i64>
pub fn open_incident( &self, monitor: &str, started: u64, error: Option<&str>, ) -> Result<i64>
Open an incident; its id.
Sourcepub fn close_incident(&self, monitor: &str, ended: u64) -> Result<()>
pub fn close_incident(&self, monitor: &str, ended: u64) -> Result<()>
End the monitor’s open incident, if any.
Sourcepub fn incidents(
&self,
monitor: Option<&str>,
limit: usize,
now: u64,
) -> Result<Vec<Incident>>
pub fn incidents( &self, monitor: Option<&str>, limit: usize, now: u64, ) -> Result<Vec<Incident>>
Incidents, newest first: one monitor’s, or every one’s.
pub fn load_state<T: for<'de> Deserialize<'de>>( &self, monitor: &str, ) -> Result<Option<T>>
pub fn save_state<T: Serialize>(&self, monitor: &str, s: &T) -> Result<()>
Auto Trait Implementations§
impl !Freeze for Db
impl !RefUnwindSafe for Db
impl !Sync for Db
impl !UnwindSafe for Db
impl Send for Db
impl Unpin for Db
impl UnsafeUnpin for Db
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more