Temporary use nostr-db as a db backend due to breaking API change in the library
47 lines
1.4 KiB
Rust
47 lines
1.4 KiB
Rust
use crate::utils::structs::Context;
|
|
use db::Noose;
|
|
use pipeline::Pipeline;
|
|
use tokio::runtime;
|
|
pub mod db;
|
|
mod nostr_db;
|
|
pub mod pipeline;
|
|
pub mod sled;
|
|
// mod sqlite;
|
|
pub mod user;
|
|
|
|
pub fn start(context: Context) {
|
|
let rt = runtime::Runtime::new().unwrap();
|
|
|
|
rt.block_on(async move {
|
|
let pipeline_pubsub = context.pubsub.clone();
|
|
let pipeline_config = context.config.clone();
|
|
|
|
let db_config = context.config.clone();
|
|
let db_pubsub = context.pubsub.clone();
|
|
let sled_pubsub = context.pubsub.clone();
|
|
|
|
let pipeline_handle = tokio::task::spawn(async move {
|
|
let mut pipeline = Pipeline::new(pipeline_pubsub, pipeline_config);
|
|
pipeline.start().await.unwrap();
|
|
});
|
|
|
|
let sled_handle = tokio::task::spawn(async move {
|
|
let mut sled_writer = sled::SledDb::new();
|
|
sled_writer.start(sled_pubsub).await.unwrap();
|
|
});
|
|
|
|
let nostr_db_writer_handle = tokio::task::spawn(async move {
|
|
let mut db_writer = nostr_db::NostrDb::new(db_config).await;
|
|
db_writer.start(db_pubsub).await.unwrap();
|
|
});
|
|
|
|
// let sqlite_writer_handle = tokio::task::spawn(async move {
|
|
// let mut db_writer = sqlite::SqliteDb::new().await;
|
|
// db_writer.start(db_pubsub).await.unwrap();
|
|
// });
|
|
|
|
// sqlite_writer_handle.await.unwrap();
|
|
pipeline_handle.await.unwrap();
|
|
});
|
|
}
|