this repo has no description
1use crate::config::AuthConfig;
2use crate::repo::PostgresBlockStore;
3use crate::storage::{BlobStorage, S3BlobStorage};
4use crate::sync::firehose::SequencedEvent;
5use sqlx::PgPool;
6use std::sync::Arc;
7use tokio::sync::broadcast;
8
9#[derive(Clone)]
10pub struct AppState {
11 pub db: PgPool,
12 pub block_store: PostgresBlockStore,
13 pub blob_store: Arc<dyn BlobStorage>,
14 pub firehose_tx: broadcast::Sender<SequencedEvent>,
15}
16
17impl AppState {
18 pub async fn new(db: PgPool) -> Self {
19 AuthConfig::init();
20
21 let block_store = PostgresBlockStore::new(db.clone());
22 let blob_store = S3BlobStorage::new().await;
23 let (firehose_tx, _) = broadcast::channel(1000);
24 Self {
25 db,
26 block_store,
27 blob_store: Arc::new(blob_store),
28 firehose_tx,
29 }
30 }
31}