very fast at protocol indexer with flexible filtering, xrpc queries, cursor-backed event stream, and more, built on fjall
rust fjall at-protocol atproto indexer
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475//! v14 is a fence for the `types::v14::RepoMetadata` shape and writes nothing. old rows still//! decode through serde defaults, but an older build can't read the longer rows, so it has to//! refuse the database at open instead of failing every metadata read. don't drop it as a no-op
use fjall::OwnedWriteBatch;use miette::Result;
use crate::db::Db;
pub(super) fn repo_metadata_v14(_db: &Db, _batch: &mut OwnedWriteBatch) -> Result<bool> { Ok(true)}
// a relay-only build never runs v8, so its version stops at 7, and nothing it writes needs this// fence anyway#[cfg(all(test, feature = "indexer"))]mod tests { use crate::config::Config; use crate::db::keys::{self, VERSIONING_KEY}; use crate::db::migration::{LATEST_VERSION, rewind_version_for_test}; use crate::db::{Db, deser_repo_meta}; use crate::types::v4; use jacquard_common::types::did::Did; use miette::{IntoDiagnostic, Result}; use tempfile::tempdir;
#[test] fn old_database_opens_at_v14_with_its_metadata_rows_untouched() -> Result<()> { let tmp = tempdir().into_diagnostic()?; let cfg = Config { database_path: tmp.path().to_path_buf(), ..Default::default() }; let did = Did::new_static("did:plc:ewvi7nxzyoun6zhxrhs64oiz").into_diagnostic()?; let old_row = rmp_serde::to_vec(&v4::RepoMetadata { tracked: true, index_id: 7, }) .into_diagnostic()?; { let db = Db::open(&cfg)?; db.repo_metadata .insert(keys::repo_metadata_key(&did), &old_row) .into_diagnostic()?; rewind_version_for_test(&db, 9)?; db.persist()?; }
let db = Db::open(&cfg)?; let version = db .counts .get(VERSIONING_KEY) .into_diagnostic()? .expect("schema version"); assert_eq!(LATEST_VERSION, 14); assert_eq!( u64::from_be_bytes(version.as_ref().try_into().into_diagnostic()?), LATEST_VERSION ); let row = db .repo_metadata .get(keys::repo_metadata_key(&did)) .into_diagnostic()? .expect("metadata row"); assert_eq!(row.as_ref(), old_row.as_slice()); let metadata = deser_repo_meta(&row)?; assert_eq!( (metadata.tracked, metadata.index_id, metadata.retry_count), (true, 7, 0) ); assert_eq!(metadata.relay_inactive, None); Ok(()) }}