at protocol indexer with flexible filtering, xrpc queries, and a cursor-backed event stream, built on fjall
at-protocol atproto indexer rust fjall
at main 42 lines 1.1 kB view raw
1use fjall::compaction::filter::Context; 2use lsm_tree::compaction::{CompactionFilter, Factory}; 3use lsm_tree::compaction::{ItemAccessor, Verdict}; 4 5mod drop_prefix { 6 use super::*; 7 8 pub struct DropPrefixFilter { 9 prefix: &'static [u8], 10 } 11 12 impl CompactionFilter for DropPrefixFilter { 13 fn filter_item( 14 &mut self, 15 item: ItemAccessor<'_>, 16 _: &Context, 17 ) -> lsm_tree::Result<Verdict> { 18 Ok(item 19 .key() 20 .starts_with(&self.prefix) 21 .then_some(Verdict::Destroy) 22 .unwrap_or(Verdict::Keep)) 23 } 24 } 25 26 pub struct DropPrefixFilterFactory { 27 pub prefix: &'static [u8], 28 } 29 30 impl Factory for DropPrefixFilterFactory { 31 fn name(&self) -> &str { 32 "drop_prefix" 33 } 34 35 fn make_filter(&self, _: &Context) -> Box<dyn CompactionFilter> { 36 Box::new(DropPrefixFilter { 37 prefix: self.prefix, 38 }) 39 } 40 } 41} 42pub use drop_prefix::*;