diff --git a/quickpeep_raker/src/storage.rs b/quickpeep_raker/src/storage.rs index 4bf5854..5a05135 100644 --- a/quickpeep_raker/src/storage.rs +++ b/quickpeep_raker/src/storage.rs @@ -15,6 +15,7 @@ use ouroboros::self_referencing; use reqwest::Url; use std::borrow::Cow; use std::path::Path; +use std::sync::atomic::AtomicU64; use std::sync::Arc; use std::time::{SystemTime, UNIX_EPOCH}; @@ -64,6 +65,7 @@ pub struct RakerDb { #[derive(Clone)] pub struct RakerStore { pub mdbx: Arc, + pub metrics: Option>, } impl RakerStore { @@ -175,6 +177,14 @@ impl RakerStore { } } +/// Optional struct to store metrics. Intended for exporting over Prometheus so we can see at a +/// glance what the shape of the datastore looks like. +pub struct RakerStoreMetrics { + pub active_domains_count: AtomicU64, + pub backoff_domains_count: AtomicU64, + pub queued_url_count: AtomicU64, +} + pub struct RakerTxn<'a, K: TransactionKind> { pub mdbx_txn: Transaction<'a, K, WriteMap>, mdbx: Arc, @@ -393,6 +403,10 @@ impl<'a> RakerTxn<'a, RW> { Ok(true) } + + pub fn calculate_initial_metrics(&self) -> anyhow::Result<()> { + todo!() + } } /// Read-only implementations (but can also be used on RW transactions)