Remove hidden but usable CLI arguments

This commit is contained in:
Clément Renault 2023-01-05 14:25:41 +01:00
parent 8a3da0c2a7
commit cda529c07b
No known key found for this signature in database
GPG Key ID: 92ADA4E935E71FA4
2 changed files with 8 additions and 31 deletions

View File

@ -281,12 +281,7 @@ impl From<Opt> for Infos {
ScheduleSnapshot::Enabled(interval) => Some(interval), ScheduleSnapshot::Enabled(interval) => Some(interval),
}; };
let IndexerOpts { let IndexerOpts { max_indexing_memory, max_indexing_threads } = indexer_options;
log_every_n: _,
max_nb_chunks: _,
max_indexing_memory,
max_indexing_threads,
} = indexer_options;
// We're going to override every sensible information. // We're going to override every sensible information.
// We consider information sensible if it contains a path, an address, or a key. // We consider information sensible if it contains a path, an address, or a key.

View File

@ -63,7 +63,7 @@ const DEFAULT_DUMP_DIR: &str = "dumps/";
const MEILI_MAX_INDEXING_MEMORY: &str = "MEILI_MAX_INDEXING_MEMORY"; const MEILI_MAX_INDEXING_MEMORY: &str = "MEILI_MAX_INDEXING_MEMORY";
const MEILI_MAX_INDEXING_THREADS: &str = "MEILI_MAX_INDEXING_THREADS"; const MEILI_MAX_INDEXING_THREADS: &str = "MEILI_MAX_INDEXING_THREADS";
const DEFAULT_LOG_EVERY_N: usize = 100000; const DEFAULT_LOG_EVERY_N: usize = 100_000;
// Each environment (index and task-db) is taking space in the virtual address space. // Each environment (index and task-db) is taking space in the virtual address space.
// //
@ -88,6 +88,7 @@ pub enum LogLevel {
pub struct LogLevelError { pub struct LogLevelError {
pub given_log_level: String, pub given_log_level: String,
} }
impl Display for LogLevelError { impl Display for LogLevelError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!( writeln!(
@ -97,6 +98,7 @@ impl Display for LogLevelError {
) )
} }
} }
impl Display for LogLevel { impl Display for LogLevel {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self { match self {
@ -109,7 +111,9 @@ impl Display for LogLevel {
} }
} }
} }
impl std::error::Error for LogLevelError {} impl std::error::Error for LogLevelError {}
impl FromStr for LogLevel { impl FromStr for LogLevel {
type Err = LogLevelError; type Err = LogLevelError;
@ -487,16 +491,6 @@ impl Opt {
#[derive(Debug, Clone, Parser, Deserialize)] #[derive(Debug, Clone, Parser, Deserialize)]
pub struct IndexerOpts { pub struct IndexerOpts {
/// Sets the amount of documents to skip before printing
/// a log regarding the indexing advancement.
#[serde(default = "default_log_every_n")]
#[clap(long, default_value_t = default_log_every_n(), hide = true)] // 100k
pub log_every_n: usize,
/// Grenad max number of chunks in bytes.
#[clap(long, hide = true)]
pub max_nb_chunks: Option<usize>,
/// Sets the maximum amount of RAM Meilisearch can use when indexing. By default, Meilisearch /// Sets the maximum amount of RAM Meilisearch can use when indexing. By default, Meilisearch
/// uses no more than two thirds of available memory. /// uses no more than two thirds of available memory.
#[clap(long, env = MEILI_MAX_INDEXING_MEMORY, default_value_t)] #[clap(long, env = MEILI_MAX_INDEXING_MEMORY, default_value_t)]
@ -514,12 +508,7 @@ pub struct IndexerOpts {
impl IndexerOpts { impl IndexerOpts {
/// Exports the values to their corresponding env vars if they are not set. /// Exports the values to their corresponding env vars if they are not set.
pub fn export_to_env(self) { pub fn export_to_env(self) {
let IndexerOpts { let IndexerOpts { max_indexing_memory, max_indexing_threads } = self;
max_indexing_memory,
max_indexing_threads,
log_every_n: _,
max_nb_chunks: _,
} = self;
if let Some(max_indexing_memory) = max_indexing_memory.0 { if let Some(max_indexing_memory) = max_indexing_memory.0 {
export_to_env_if_not_present( export_to_env_if_not_present(
MEILI_MAX_INDEXING_MEMORY, MEILI_MAX_INDEXING_MEMORY,
@ -543,8 +532,7 @@ impl TryFrom<&IndexerOpts> for IndexerConfig {
.build()?; .build()?;
Ok(Self { Ok(Self {
log_every_n: Some(other.log_every_n), log_every_n: Some(DEFAULT_LOG_EVERY_N),
max_nb_chunks: other.max_nb_chunks,
max_memory: other.max_indexing_memory.map(|b| b.get_bytes() as usize), max_memory: other.max_indexing_memory.map(|b| b.get_bytes() as usize),
thread_pool: Some(thread_pool), thread_pool: Some(thread_pool),
max_positions_per_attributes: None, max_positions_per_attributes: None,
@ -556,8 +544,6 @@ impl TryFrom<&IndexerOpts> for IndexerConfig {
impl Default for IndexerOpts { impl Default for IndexerOpts {
fn default() -> Self { fn default() -> Self {
Self { Self {
log_every_n: 100_000,
max_nb_chunks: None,
max_indexing_memory: MaxMemory::default(), max_indexing_memory: MaxMemory::default(),
max_indexing_threads: MaxThreads::default(), max_indexing_threads: MaxThreads::default(),
} }
@ -748,10 +734,6 @@ fn default_dump_dir() -> PathBuf {
PathBuf::from(DEFAULT_DUMP_DIR) PathBuf::from(DEFAULT_DUMP_DIR)
} }
fn default_log_every_n() -> usize {
DEFAULT_LOG_EVERY_N
}
/// Indicates if a snapshot was scheduled, and if yes with which interval. /// Indicates if a snapshot was scheduled, and if yes with which interval.
#[derive(Debug, Default, Copy, Clone, Deserialize, Serialize)] #[derive(Debug, Default, Copy, Clone, Deserialize, Serialize)]
pub enum ScheduleSnapshot { pub enum ScheduleSnapshot {