pub struct PerfReader { /* private fields */ }Expand description
A live PostgreSQL connection pool for reading the change-log contract view.
Implementations§
Source§impl PerfReader
impl PerfReader
Sourcepub fn connect(db_url: &str) -> Result<Self>
pub fn connect(db_url: &str) -> Result<Self>
Connect to db_url (PostgreSQL only) for change-log reads.
§Errors
Returns an error if db_url is not a postgres:// URL or the pool cannot
be created. (Connection failures surface lazily on first query.)
Sourcepub async fn db_now_epoch(&self) -> Result<f64>
pub async fn db_now_epoch(&self) -> Result<f64>
The database clock as a Unix epoch in seconds — the reference the analysis windows back from, so there is no app↔DB skew at the window boundary.
§Errors
Returns an error if the connection or the query fails.
Sourcepub async fn load_samples(
&self,
window_days: i32,
object_type: Option<&str>,
) -> Result<Vec<ChangeLogSample>>
pub async fn load_samples( &self, window_days: i32, object_type: Option<&str>, ) -> Result<Vec<ChangeLogSample>>
Load every change-log sample within the trailing window_days window,
optionally restricted to a single object_type.
The window is applied in SQL (created_at >= now() - make_interval(days => $1)) so only the rows the analysis needs cross the wire.
§Errors
Returns an error if the connection or the query fails.
Auto Trait Implementations§
impl !RefUnwindSafe for PerfReader
impl !UnwindSafe for PerfReader
impl Freeze for PerfReader
impl Send for PerfReader
impl Sync for PerfReader
impl Unpin for PerfReader
impl UnsafeUnpin for PerfReader
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more