Patch the IndexScheduler in meilisearch-http to use the options struct

This commit is contained in:
Kerollmops 2022-10-26 11:47:49 +02:00 committed by Clément Renault
parent eccbdb74cf
commit 2f577b6fcd
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
2 changed files with 25 additions and 25 deletions

View File

@ -206,28 +206,28 @@ pub enum Breakpoint {
#[derive(Debug)] #[derive(Debug)]
pub struct IndexSchedulerOptions { pub struct IndexSchedulerOptions {
/// The path to the version file of Meilisearch. /// The path to the version file of Meilisearch.
version_file_path: PathBuf, pub version_file_path: PathBuf,
/// The path to the folder containing the auth LMDB env. /// The path to the folder containing the auth LMDB env.
auth_path: PathBuf, pub auth_path: PathBuf,
/// The path to the folder containing the task databases. /// The path to the folder containing the task databases.
tasks_path: PathBuf, pub tasks_path: PathBuf,
/// The path to the file store containing the files associated to the tasks. /// The path to the file store containing the files associated to the tasks.
update_file_path: PathBuf, pub update_file_path: PathBuf,
/// The path to the folder containing meilisearch's indexes. /// The path to the folder containing meilisearch's indexes.
indexes_path: PathBuf, pub indexes_path: PathBuf,
/// The path to the folder containing the snapshots. /// The path to the folder containing the snapshots.
snapshots_path: PathBuf, pub snapshots_path: PathBuf,
/// The path to the folder containing the dumps. /// The path to the folder containing the dumps.
dumps_path: PathBuf, pub dumps_path: PathBuf,
/// The maximum size, in bytes, of each meilisearch index. /// The maximum size, in bytes, of each meilisearch index.
task_db_size: usize, pub task_db_size: usize,
/// The maximum size, in bytes, of the tasks index. /// The maximum size, in bytes, of the tasks index.
index_size: usize, pub index_size: usize,
/// Configuration used during indexing for each meilisearch index. /// Configuration used during indexing for each meilisearch index.
indexer_config: IndexerConfig, pub indexer_config: IndexerConfig,
/// Set to `true` iff the index scheduler is allowed to automatically /// Set to `true` iff the index scheduler is allowed to automatically
/// batch tasks together, to process multiple tasks at once. /// batch tasks together, to process multiple tasks at once.
autobatching_enabled: bool, pub autobatching_enabled: bool,
} }
/// Structure which holds meilisearch's indexes and schedules the tasks /// Structure which holds meilisearch's indexes and schedules the tasks

View File

@ -32,7 +32,7 @@ use anyhow::bail;
use error::PayloadError; use error::PayloadError;
use extractors::payload::PayloadConfig; use extractors::payload::PayloadConfig;
use http::header::CONTENT_TYPE; use http::header::CONTENT_TYPE;
use index_scheduler::IndexScheduler; use index_scheduler::{IndexScheduler, IndexSchedulerOptions};
use log::error; use log::error;
use meilisearch_auth::AuthController; use meilisearch_auth::AuthController;
use meilisearch_types::milli::documents::{DocumentsBatchBuilder, DocumentsBatchReader}; use meilisearch_types::milli::documents::{DocumentsBatchBuilder, DocumentsBatchReader};
@ -114,19 +114,19 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(Arc<IndexScheduler>, Auth
// wrap our two builders in a closure that'll be executed later. // wrap our two builders in a closure that'll be executed later.
let auth_controller_builder = || AuthController::new(&opt.db_path, &opt.master_key); let auth_controller_builder = || AuthController::new(&opt.db_path, &opt.master_key);
let index_scheduler_builder = || { let index_scheduler_builder = || {
IndexScheduler::new( IndexScheduler::new(IndexSchedulerOptions {
opt.db_path.join(VERSION_FILE_NAME), version_file_path: opt.db_path.join(VERSION_FILE_NAME),
opt.db_path.join("auth"), auth_path: opt.db_path.join("auth"),
opt.db_path.join("tasks"), tasks_path: opt.db_path.join("tasks"),
opt.db_path.join("update_files"), update_file_path: opt.db_path.join("update_files"),
opt.db_path.join("indexes"), indexes_path: opt.db_path.join("indexes"),
opt.snapshot_dir.clone(), snapshots_path: opt.snapshot_dir.clone(),
opt.dumps_dir.clone(), dumps_path: opt.dumps_dir.clone(),
opt.max_task_db_size.get_bytes() as usize, task_db_size: opt.max_task_db_size.get_bytes() as usize,
opt.max_index_size.get_bytes() as usize, index_size: opt.max_index_size.get_bytes() as usize,
(&opt.indexer_options).try_into()?, indexer_config: (&opt.indexer_options).try_into()?,
true, autobatching_enabled: !opt.scheduler_options.disable_auto_batching,
) })
}; };
let meilisearch_builder = || -> anyhow::Result<_> { let meilisearch_builder = || -> anyhow::Result<_> {
// if anything wrong happens we delete the `data.ms` entirely. // if anything wrong happens we delete the `data.ms` entirely.