Rename PostSaver into PostIndexer, which is a better name

This commit is contained in:
Aleksei Voronov 2023-09-16 17:16:01 +02:00
parent b4250e12cd
commit 227118dfb1
3 changed files with 8 additions and 8 deletions

View File

@ -6,7 +6,7 @@ use anyhow::Result;
use crate::config::Config;
use crate::processes::feed_server::FeedServer;
use crate::processes::post_saver::PostSaver;
use crate::processes::post_indexer::PostIndexer;
use crate::processes::profile_classifier::ProfileClassifier;
use crate::services::ai::AI;
use crate::services::bluesky::Bluesky;
@ -20,12 +20,12 @@ async fn main() -> Result<()> {
let bluesky = Bluesky::new("https://bsky.social");
let database = Database::connect(&config.database_url).await?;
let post_saver = PostSaver::new(&database, &bluesky);
let post_indexer = PostIndexer::new(&database, &bluesky);
let profile_classifier = ProfileClassifier::new(&database, &ai, &bluesky);
let feed_server = FeedServer::new(&database, &config);
tokio::try_join!(
post_saver.start(),
post_indexer.start(),
profile_classifier.start(),
feed_server.serve(),
)?;

View File

@ -1,3 +1,3 @@
pub mod feed_server;
pub mod post_saver;
pub mod post_indexer;
pub mod profile_classifier;

View File

@ -4,25 +4,25 @@ use async_trait::async_trait;
use crate::services::bluesky::{Bluesky, Operation, OperationProcessor};
use crate::services::database::Database;
pub struct PostSaver<'a> {
pub struct PostIndexer<'a> {
database: &'a Database,
bluesky: &'a Bluesky,
}
impl<'a> PostSaver<'a> {
impl<'a> PostIndexer<'a> {
pub fn new(database: &'a Database, bluesky: &'a Bluesky) -> Self {
Self { database, bluesky }
}
}
impl<'a> PostSaver<'a> {
impl<'a> PostIndexer<'a> {
pub async fn start(&self) -> Result<()> {
Ok(self.bluesky.subscribe_to_operations(self).await?)
}
}
#[async_trait]
impl<'a> OperationProcessor for PostSaver<'a> {
impl<'a> OperationProcessor for PostIndexer<'a> {
async fn process_operation(&self, operation: &Operation) -> Result<()> {
match operation {
Operation::CreatePost {