mirror of
https://github.com/meilisearch/meilisearch.git
synced 2025-09-04 11:46:30 +00:00
Support legacy cli arguments
This commit is contained in:
@ -107,10 +107,6 @@ pub struct IndexSchedulerOptions {
|
|||||||
pub snapshots_path: PathBuf,
|
pub snapshots_path: PathBuf,
|
||||||
/// The path to the folder containing the dumps.
|
/// The path to the folder containing the dumps.
|
||||||
pub dumps_path: PathBuf,
|
pub dumps_path: PathBuf,
|
||||||
/// The URL on which we must send the tasks statuses
|
|
||||||
pub webhook_url: Option<String>,
|
|
||||||
/// The value we will send into the Authorization HTTP header on the webhook URL
|
|
||||||
pub webhook_authorization_header: Option<String>,
|
|
||||||
/// The maximum size, in bytes, of the task index.
|
/// The maximum size, in bytes, of the task index.
|
||||||
pub task_db_size: usize,
|
pub task_db_size: usize,
|
||||||
/// The size, in bytes, with which a meilisearch index is opened the first time of each meilisearch index.
|
/// The size, in bytes, with which a meilisearch index is opened the first time of each meilisearch index.
|
||||||
|
@ -98,8 +98,6 @@ impl IndexScheduler {
|
|||||||
indexes_path: tempdir.path().join("indexes"),
|
indexes_path: tempdir.path().join("indexes"),
|
||||||
snapshots_path: tempdir.path().join("snapshots"),
|
snapshots_path: tempdir.path().join("snapshots"),
|
||||||
dumps_path: tempdir.path().join("dumps"),
|
dumps_path: tempdir.path().join("dumps"),
|
||||||
webhook_url: None,
|
|
||||||
webhook_authorization_header: None,
|
|
||||||
task_db_size: 1000 * 1000 * 10, // 10 MB, we don't use MiB on purpose.
|
task_db_size: 1000 * 1000 * 10, // 10 MB, we don't use MiB on purpose.
|
||||||
index_base_map_size: 1000 * 1000, // 1 MB, we don't use MiB on purpose.
|
index_base_map_size: 1000 * 1000, // 1 MB, we don't use MiB on purpose.
|
||||||
enable_mdb_writemap: false,
|
enable_mdb_writemap: false,
|
||||||
|
@ -2,7 +2,7 @@ use std::collections::BTreeMap;
|
|||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct Webhook {
|
pub struct Webhook {
|
||||||
pub url: String,
|
pub url: String,
|
||||||
|
@ -13,6 +13,7 @@ pub mod routes;
|
|||||||
pub mod search;
|
pub mod search;
|
||||||
pub mod search_queue;
|
pub mod search_queue;
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{BufReader, BufWriter};
|
use std::io::{BufReader, BufWriter};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@ -48,6 +49,7 @@ use meilisearch_types::tasks::KindWithContent;
|
|||||||
use meilisearch_types::versioning::{
|
use meilisearch_types::versioning::{
|
||||||
create_current_version_file, get_version, VersionFileError, VERSION_MINOR, VERSION_PATCH,
|
create_current_version_file, get_version, VersionFileError, VERSION_MINOR, VERSION_PATCH,
|
||||||
};
|
};
|
||||||
|
use meilisearch_types::webhooks::Webhook;
|
||||||
use meilisearch_types::{compression, heed, milli, VERSION_FILE_NAME};
|
use meilisearch_types::{compression, heed, milli, VERSION_FILE_NAME};
|
||||||
pub use option::Opt;
|
pub use option::Opt;
|
||||||
use option::ScheduleSnapshot;
|
use option::ScheduleSnapshot;
|
||||||
@ -223,8 +225,6 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(Arc<IndexScheduler>, Arc<
|
|||||||
indexes_path: opt.db_path.join("indexes"),
|
indexes_path: opt.db_path.join("indexes"),
|
||||||
snapshots_path: opt.snapshot_dir.clone(),
|
snapshots_path: opt.snapshot_dir.clone(),
|
||||||
dumps_path: opt.dump_dir.clone(),
|
dumps_path: opt.dump_dir.clone(),
|
||||||
webhook_url: opt.task_webhook_url.as_ref().map(|url| url.to_string()),
|
|
||||||
webhook_authorization_header: opt.task_webhook_authorization_header.clone(),
|
|
||||||
task_db_size: opt.max_task_db_size.as_u64() as usize,
|
task_db_size: opt.max_task_db_size.as_u64() as usize,
|
||||||
index_base_map_size: opt.max_index_size.as_u64() as usize,
|
index_base_map_size: opt.max_index_size.as_u64() as usize,
|
||||||
enable_mdb_writemap: opt.experimental_reduce_indexing_memory_usage,
|
enable_mdb_writemap: opt.experimental_reduce_indexing_memory_usage,
|
||||||
@ -327,6 +327,30 @@ pub fn setup_meilisearch(opt: &Opt) -> anyhow::Result<(Arc<IndexScheduler>, Arc<
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We set the webhook url
|
||||||
|
let cli_webhook = opt.task_webhook_url.as_ref().map(|u| Webhook {
|
||||||
|
url: u.to_string(),
|
||||||
|
headers: {
|
||||||
|
let mut headers = BTreeMap::new();
|
||||||
|
if let Some(value) = &opt.task_webhook_authorization_header {
|
||||||
|
headers.insert(String::from("Authorization"), value.to_string());
|
||||||
|
}
|
||||||
|
headers
|
||||||
|
},
|
||||||
|
});
|
||||||
|
let mut webhooks = index_scheduler.webhooks();
|
||||||
|
if webhooks.webhooks.get("_cli") != cli_webhook.as_ref() {
|
||||||
|
match cli_webhook {
|
||||||
|
Some(webhook) => {
|
||||||
|
webhooks.webhooks.insert("_cli".to_string(), webhook);
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
webhooks.webhooks.remove("_cli");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
index_scheduler.put_webhooks(webhooks)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok((index_scheduler, auth_controller))
|
Ok((index_scheduler, auth_controller))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,11 +206,13 @@ pub struct Opt {
|
|||||||
pub env: String,
|
pub env: String,
|
||||||
|
|
||||||
/// Called whenever a task finishes so a third party can be notified.
|
/// Called whenever a task finishes so a third party can be notified.
|
||||||
|
/// See also the dedicated API `/webhooks`.
|
||||||
#[clap(long, env = MEILI_TASK_WEBHOOK_URL)]
|
#[clap(long, env = MEILI_TASK_WEBHOOK_URL)]
|
||||||
pub task_webhook_url: Option<Url>,
|
pub task_webhook_url: Option<Url>,
|
||||||
|
|
||||||
/// The Authorization header to send on the webhook URL whenever
|
/// The Authorization header to send on the webhook URL whenever
|
||||||
/// a task finishes so a third party can be notified.
|
/// a task finishes so a third party can be notified.
|
||||||
|
/// See also the dedicated API `/webhooks`.
|
||||||
#[clap(long, env = MEILI_TASK_WEBHOOK_AUTHORIZATION_HEADER)]
|
#[clap(long, env = MEILI_TASK_WEBHOOK_AUTHORIZATION_HEADER)]
|
||||||
pub task_webhook_authorization_header: Option<String>,
|
pub task_webhook_authorization_header: Option<String>,
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user