Convert into more modern Rust module structure

And also use re-exports liberally for shorter imports
This commit is contained in:
Aleksei Voronov 2023-09-16 17:21:18 +02:00
parent 227118dfb1
commit 944be0cd5a
10 changed files with 26 additions and 18 deletions

View File

@ -5,12 +5,12 @@ mod services;
use anyhow::Result; use anyhow::Result;
use crate::config::Config; use crate::config::Config;
use crate::processes::feed_server::FeedServer; use crate::processes::FeedServer;
use crate::processes::post_indexer::PostIndexer; use crate::processes::PostIndexer;
use crate::processes::profile_classifier::ProfileClassifier; use crate::processes::ProfileClassifier;
use crate::services::ai::AI; use crate::services::AI;
use crate::services::bluesky::Bluesky; use crate::services::Bluesky;
use crate::services::database::Database; use crate::services::Database;
#[tokio::main] #[tokio::main]
async fn main() -> Result<()> { async fn main() -> Result<()> {

7
src/processes.rs Normal file
View File

@ -0,0 +1,7 @@
mod feed_server;
mod post_indexer;
mod profile_classifier;
pub use feed_server::FeedServer;
pub use post_indexer::PostIndexer;
pub use profile_classifier::ProfileClassifier;

View File

@ -5,7 +5,7 @@ use axum::routing::get;
use axum::{Router, Server}; use axum::{Router, Server};
use crate::config::Config; use crate::config::Config;
use crate::services::database::Database; use crate::services::Database;
use super::endpoints::{describe_feed_generator, did_json, get_feed_skeleton, root}; use super::endpoints::{describe_feed_generator, did_json, get_feed_skeleton, root};
use super::state::FeedServerState; use super::state::FeedServerState;

View File

@ -1,5 +1,5 @@
use crate::config::Config; use crate::config::Config;
use crate::services::database::Database; use crate::services::Database;
#[derive(Clone)] #[derive(Clone)]
pub struct FeedServerState { pub struct FeedServerState {

View File

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

View File

@ -2,7 +2,7 @@ use anyhow::Result;
use async_trait::async_trait; use async_trait::async_trait;
use crate::services::bluesky::{Bluesky, Operation, OperationProcessor}; use crate::services::bluesky::{Bluesky, Operation, OperationProcessor};
use crate::services::database::Database; use crate::services::Database;
pub struct PostIndexer<'a> { pub struct PostIndexer<'a> {
database: &'a Database, database: &'a Database,

View File

@ -2,9 +2,9 @@ use std::time::Duration;
use anyhow::Result; use anyhow::Result;
use crate::services::ai::AI; use crate::services::AI;
use crate::services::bluesky::Bluesky; use crate::services::Bluesky;
use crate::services::database::Database; use crate::services::Database;
pub struct ProfileClassifier<'a> { pub struct ProfileClassifier<'a> {
database: &'a Database, database: &'a Database,

7
src/services.rs Normal file
View File

@ -0,0 +1,7 @@
mod ai;
pub mod bluesky;
mod database;
pub use ai::AI;
pub use bluesky::Bluesky;
pub use database::Database;

View File

@ -1,3 +0,0 @@
pub mod ai;
pub mod bluesky;
pub mod database;