at protocol indexer with flexible filtering, xrpc queries, and a cursor-backed event stream, built on fjall
at-protocol atproto indexer rust fjall
at 25e6d3c7400a40dfbadcae56258603ec3353c476 31 lines 718 B view raw
1use std::sync::atomic::AtomicI64; 2 3use miette::Result; 4use tokio::sync::Notify; 5 6use crate::{config::Config, db::Db, resolver::Resolver}; 7 8pub struct AppState { 9 pub db: Db, 10 pub resolver: Resolver, 11 pub cur_firehose: AtomicI64, 12 pub backfill_notify: Notify, 13} 14 15impl AppState { 16 pub fn new(config: &Config) -> Result<Self> { 17 let db = Db::open(config)?; 18 let resolver = Resolver::new(config.plc_urls.clone(), config.identity_cache_size); 19 20 Ok(Self { 21 db, 22 resolver, 23 cur_firehose: AtomicI64::new(0), 24 backfill_notify: Notify::new(), 25 }) 26 } 27 28 pub fn notify_backfill(&self) { 29 self.backfill_notify.notify_one(); 30 } 31}