STASH to calculate datastore metrics
continuous-integration/drone the build failed Details

This commit is contained in:
Olivier 'reivilibre' 2022-03-20 13:26:34 +00:00
parent 410a4e962b
commit e651a953f6
1 changed files with 14 additions and 0 deletions

View File

@ -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<RakerDb>,
pub metrics: Option<Arc<RakerStoreMetrics>>,
}
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<RakerDb>,
@ -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)