refactor(server): indexer & worker & sync perf (#15504)

This commit is contained in:
DarkSky
2026-08-21 08:11:37 +08:00
committed by GitHub
parent 8c9aad9a9b
commit c57004ea2c
259 changed files with 16530 additions and 17793 deletions
@@ -4,20 +4,18 @@ use affine_schema::{
get_migrator,
import_validation::{V2_IMPORT_SCHEMA_RULES, validate_import_schema, validate_required_schema},
};
use memory_indexer::InMemoryIndex;
use sqlx::{
Pool, Row,
migrate::{MigrateDatabase, Migration, Migrator},
sqlite::{Sqlite, SqliteConnectOptions, SqlitePoolOptions},
};
use tokio::sync::RwLock;
use super::error::Result;
use super::{error::Result, indexer::IndexManager};
pub struct SqliteDocStorage {
pub pool: Pool<Sqlite>,
path: String,
pub index: Arc<RwLock<InMemoryIndex>>,
pub indexes: Arc<IndexManager>,
}
impl SqliteDocStorage {
@@ -26,7 +24,7 @@ impl SqliteDocStorage {
let mut pool_options = SqlitePoolOptions::new();
let index = Arc::new(RwLock::new(InMemoryIndex::default()));
let indexes = Arc::new(IndexManager::new());
if path == ":memory:" {
pool_options = pool_options
@@ -38,7 +36,7 @@ impl SqliteDocStorage {
Self {
pool: pool_options.connect_lazy_with(sqlite_options),
path,
index,
indexes,
}
} else {
Self {
@@ -46,7 +44,7 @@ impl SqliteDocStorage {
.max_connections(4)
.connect_lazy_with(sqlite_options.journal_mode(sqlx::sqlite::SqliteJournalMode::Wal)),
path,
index,
indexes,
}
}
}