mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-02 06:39:46 +08:00
refactor(server): indexer & worker & sync perf (#15504)
This commit is contained in:
@@ -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,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user