diff options
Diffstat (limited to 'src/db/mod.rs')
| -rw-r--r-- | src/db/mod.rs | 67 |
1 files changed, 26 insertions, 41 deletions
diff --git a/src/db/mod.rs b/src/db/mod.rs index d4befcc..13d7d9d 100644 --- a/src/db/mod.rs +++ b/src/db/mod.rs @@ -25,32 +25,32 @@ mod subscriptions; mod world; pub use migrations::MIGRATIONS; +pub(crate) use model::StateEnum; +pub(crate) use model::json_or; pub use model::{ - BUILD_STEPS, BuildState, CandidateRow, CandidateState, Identity, Recipe, ReleaseRow, - ReleaseState, SourceDigest, SourceEntry, StageBCacheRow, StateEnum, StepState, - SubscriptionState, UpstreamPin, WorldMember, candidate_kind, json_or, notice_kind, + BUILD_STEPS, BuildState, CandidateRow, CandidateState, + Identity, Recipe, ReleaseRow, ReleaseState, + SourceDigest, SourceEntry, StageBCacheRow, StepState, + SubscriptionState, UpstreamPin, WorldMember, candidate_kind, + notice_kind, }; -pub use audit::{AuditEntry, AuditRow, audit, audit_in, audit_system, list_audit}; -pub use invariants::{Unbuilt, approved_but_unbuilt, index_pkgbase_drift, unapproved_index_entries}; +pub use audit::{AuditEntry, audit, audit_in, audit_system, list_audit}; +pub use invariants::{approved_but_unbuilt, unapproved_index_entries}; pub use metrics::{ artifact_bytes_served, build_state_counts, count_index_packages, count_pending_reviews, - count_published_releases, count_subscriptions, count_unacknowledged_notices, - last_gc_age_secs, last_poll_age_secs, oldest_queued_age_secs, pending_review_ages_secs, + count_published_releases, count_subscriptions, count_unacknowledged_notices, last_gc_age_secs, + last_poll_age_secs, oldest_queued_age_secs, pending_review_ages_secs, }; -pub use notices::{NoticeRow, acknowledge_notice, list_notices, put_notice, put_notice_once}; +pub use notices::{acknowledge_notice, list_notices, put_notice_once}; pub use packages::{ - PackageRow, accepted_recipe, builds_for_pkgbase, index_artifact, index_packages, - index_version, is_ours, our_package_names, -}; -pub use pkgbases::{ - Pkgbase, cas_accepted_release, get_pkgbase, get_pkgbase_by_id, list_pkgbases, set_aur_head, - set_unpinable, + accepted_recipe, builds_for_pkgbase, index_artifact, index_packages, + index_version, our_package_names, }; +pub use pkgbases::{Pkgbase, cas_accepted_release, get_pkgbase, get_pkgbase_by_id, set_aur_head}; pub use publish_writes::{ - NewRelease, accepted_pointer_in, artifact_id_by_digest_in, artifact_path, - cas_accepted_release_in, insert_package_in, insert_release_in, remove_index_packages_in, - remove_package_by_name_in, + NewRelease, accepted_pointer_in, artifact_path, cas_accepted_release_in, + insert_package_in, insert_release_in, remove_index_packages_in, remove_package_by_name_in, }; pub use releases::{ accepted_release, all_published_releases, release_by_id, releases_for_pkgbase, @@ -58,19 +58,19 @@ pub use releases::{ }; pub use repos::{ensure_repo, repo_id}; pub use retention::{ - ArtifactPaths, mark_release_purged, pkgbase_release_pointers, published_release_ids, - record_gc_run, release_artifact_paths, serving_release_ids, + mark_release_purged, pkgbase_release_pointers, published_release_ids, record_gc_run, + release_artifact_paths, serving_release_ids, }; pub use settings::{all_settings, set_setting, setting, setting_i64}; pub use snapshots::{SnapshotRow, put_snapshot, snapshot_by_commit, snapshot_by_id}; pub use stage_b::{stage_b_cache_get, stage_b_cache_put, stage_b_recent}; pub use staleness::{ - NewArtifact, approval_note, candidate_snapshot_id, index_recipes, insert_artifact_in, - published_world_members, put_source_cache, served_vs_offered_pkgvers, source_cache_path, - subscription_poll_interval, + NewArtifact, approval_note, candidate_snapshot_id, index_recipes, + insert_artifact_in, published_world_members, put_source_cache, served_vs_offered_pkgvers, + source_cache_path, }; pub use subscriptions::{ - Subscription, due_subscriptions, get_subscription, list_subscriptions, note_check, + due_subscriptions, get_subscription, list_subscriptions, note_check, set_subscription_state, subscribe, }; pub use world::{put_world_snapshot, world_members}; @@ -88,7 +88,6 @@ pub(crate) fn state_col<T: StateEnum>(col: usize, text: &str) -> rusqlite::Resul }) } - use std::path::{Path, PathBuf}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; @@ -197,7 +196,7 @@ impl Writer { &self.path } - pub fn is_alive(&self) -> bool { + fn is_alive(&self) -> bool { self.alive.load(Ordering::SeqCst) } @@ -256,16 +255,9 @@ impl Writer { { self.tx(f) } - - pub fn call_for_tests<T>(&self, f: impl FnOnce(&mut Connection) -> Result<T> + Send + 'static) -> Result<T> - where - T: Send + 'static, - { - self.call(f) - } } -pub struct Readers { +pub(crate) struct Readers { path: PathBuf, } @@ -300,7 +292,7 @@ impl Readers { #[derive(Clone)] pub struct Db { pub writer: Arc<Writer>, - pub readers: Arc<Readers>, + pub(crate) readers: Arc<Readers>, } impl Db { @@ -338,10 +330,3 @@ pub fn schema_version(path: &Path) -> Result<i64> { .map_err(|e| Error::db(format!("{} has no schema version: {e}", path.display()))) } -pub fn wal_stats(db: &Db) -> (u64, u64) { - let db_file = std::fs::metadata(db.writer.path()).map(|m| m.len()).unwrap_or(0); - let mut wal = db.writer.path().as_os_str().to_os_string(); - wal.push("-wal"); - let wal_file = std::fs::metadata(&wal).map(|m| m.len()).unwrap_or(0); - (db_file, wal_file) -} |
