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
59
fork

Configure Feed

Select the types of activity you want to include in your feed.

[all] simplify code depending on block storage being enabled

dawn 03bfa99c 6d64eb9a

+22 -11
+2 -1
src/api/mod.rs
··· 20 20 mod xrpc; 21 21 22 22 pub async fn serve(hydrant: Hydrant, port: u16) -> miette::Result<()> { 23 + let blocks_available = hydrant.state.is_block_storage_enabled(); 23 24 let app = Router::new() 24 25 .route( 25 26 "/", ··· 41 42 #[cfg(feature = "indexer")] 42 43 let app = app.nest("/stream", stream::router()); 43 44 let app = app 44 - .merge(xrpc::router()) 45 + .merge(xrpc::router(blocks_available)) 45 46 .merge(filter::router()) 46 47 .merge(pds::router()) 47 48 .merge(repos::router())
+10 -4
src/api/xrpc/mod.rs
··· 64 64 #[cfg(feature = "relay")] 65 65 mod subscribe_repos; 66 66 67 - pub fn router() -> Router<Hydrant> { 67 + pub fn router(blocks_available: bool) -> Router<Hydrant> { 68 68 let r = Router::new() 69 69 .route(GetHostStatusRequest::PATH, get(get_host_status::handle)) 70 70 .route(ListHostsRequest::PATH, get(list_hosts::handle)) ··· 74 74 75 75 #[cfg(feature = "indexer")] 76 76 let r = r 77 - .route(GetRecordRequest::PATH, get(get_record::handle)) 78 - .route(ListRecordsRequest::PATH, get(list_records::handle)) 79 77 .route(CountRecords::PATH, get(count_records::handle)) 80 - .route(GetRepoRequest::PATH, get(get_repo::handle)) 81 78 .route(DescribeRepo::PATH, get(describe_repo::handle)) 82 79 .route( 83 80 AtprotoDescribeRepoRequest::PATH, 84 81 get(com_atproto_describe_repo::handle), 85 82 ); 83 + 84 + #[cfg(feature = "indexer")] 85 + let r = if blocks_available { 86 + r.route(GetRecordRequest::PATH, get(get_record::handle)) 87 + .route(ListRecordsRequest::PATH, get(list_records::handle)) 88 + .route(GetRepoRequest::PATH, get(get_repo::handle)) 89 + } else { 90 + r 91 + }; 86 92 87 93 #[cfg(feature = "relay")] 88 94 let r = r
+6 -6
src/control/repos/indexer.rs
··· 334 334 impl<'i> RepoHandle<'i> { 335 335 /// gets a record from this repository. 336 336 pub async fn get_record(&self, collection: &str, rkey: &str) -> Result<Option<Record>> { 337 - if self.state.only_index_links { 338 - miette::bail!("block storage is disabled (HYDRANT_ONLY_INDEX_LINKS)"); 337 + if !self.state.is_block_storage_enabled() { 338 + miette::bail!("block storage is not available in this mode"); 339 339 } 340 340 341 341 let did = self.did.clone().into_static(); ··· 380 380 reverse: bool, 381 381 cursor: Option<&str>, 382 382 ) -> Result<RecordList> { 383 - if self.state.only_index_links { 384 - miette::bail!("block storage is disabled (HYDRANT_ONLY_INDEX_LINKS)"); 383 + if !self.state.is_block_storage_enabled() { 384 + miette::bail!("block storage is not available in this mode"); 385 385 } 386 386 let did = self.did.clone().into_static(); 387 387 ··· 486 486 &self, 487 487 ) -> Result<Option<impl futures::Stream<Item = std::io::Result<bytes::Bytes>> + Send + 'static>> 488 488 { 489 - if self.state.only_index_links { 490 - miette::bail!("block storage is disabled (HYDRANT_ONLY_INDEX_LINKS)"); 489 + if !self.state.is_block_storage_enabled() { 490 + miette::bail!("block storage is not available in this mode"); 491 491 } 492 492 use iroh_car::{CarHeader, CarWriter}; 493 493 use jacquard_repo::{BlockStore, MemoryBlockStore, Mst};
+4
src/state.rs
··· 115 115 }) 116 116 } 117 117 118 + pub fn is_block_storage_enabled(&self) -> bool { 119 + !self.ephemeral && !self.only_index_links 120 + } 121 + 118 122 #[cfg(feature = "indexer")] 119 123 pub fn notify_backfill(&self) { 120 124 self.backfill_notify.notify_one();