From f86c349bef5efdba24bed38c3f029fef530fa6a5 Mon Sep 17 00:00:00 2001 From: Evance Soumaoro Date: Thu, 29 Jun 2023 17:05:10 +0000 Subject: [PATCH] cargo fmt --- .../src/elastic_search_api/filter.rs | 11 +++----- .../src/elastic_search_api/mod.rs | 4 +-- .../src/elastic_search_api/rest_handler.rs | 26 ++++++++++--------- .../quickwit-serve/src/node_info_handler.rs | 15 +++++------ quickwit/quickwit-serve/src/openapi.rs | 3 ++- 5 files changed, 29 insertions(+), 30 deletions(-) diff --git a/quickwit/quickwit-serve/src/elastic_search_api/filter.rs b/quickwit/quickwit-serve/src/elastic_search_api/filter.rs index c3c6646be26..d8a76d7602b 100644 --- a/quickwit/quickwit-serve/src/elastic_search_api/filter.rs +++ b/quickwit/quickwit-serve/src/elastic_search_api/filter.rs @@ -29,21 +29,18 @@ use crate::elastic_search_api::model::{ElasticIngestOptions, SearchBody, SearchQ const BODY_LENGTH_LIMIT: Byte = byte_unit::Byte::from_bytes(1_000_000); const CONTENT_LENGTH_LIMIT: Byte = byte_unit::Byte::from_bytes(10 * 1024 * 1024); // 10MiB -// TODO: make the models utoipa compatible and register +// TODO: make the models utoipa compatible and register // all endpoints in the docs here. #[derive(utoipa::OpenApi)] -#[openapi(paths( - elastic_info_filter, -))] +#[openapi(paths(elastic_info_filter,))] pub struct ElasticCompatibleApi; #[utoipa::path(get, tag = "Cluster Info", path = "/_elastic")] -pub(crate) fn elastic_info_filter( -) -> impl Filter + Clone { +pub(crate) fn elastic_info_filter() -> impl Filter + Clone { warp::path!("_elastic") .and(warp::get()) .and(warp::path::end()) - // .and(serde_qs::warp::query(serde_qs::Config::default())) + // .and(serde_qs::warp::query(serde_qs::Config::default())) } #[utoipa::path(get, tag = "Search", path = "/_search")] diff --git a/quickwit/quickwit-serve/src/elastic_search_api/mod.rs b/quickwit/quickwit-serve/src/elastic_search_api/mod.rs index a12c432d316..a01190c3859 100644 --- a/quickwit/quickwit-serve/src/elastic_search_api/mod.rs +++ b/quickwit/quickwit-serve/src/elastic_search_api/mod.rs @@ -25,15 +25,15 @@ mod rest_handler; use std::sync::Arc; use bulk::{es_compat_bulk_handler, es_compat_index_bulk_handler}; +pub use filter::ElasticCompatibleApi; use quickwit_ingest::IngestServiceClient; use quickwit_search::SearchService; +pub use rest_handler::es_compat_info_handler; use rest_handler::{ es_compat_index_multi_search_handler, es_compat_index_search_handler, es_compat_search_handler, }; use serde::{Deserialize, Serialize}; use warp::{Filter, Rejection}; -pub use rest_handler::es_compat_info_handler; -pub use filter::ElasticCompatibleApi; /// Setup Elasticsearch API handlers /// diff --git a/quickwit/quickwit-serve/src/elastic_search_api/rest_handler.rs b/quickwit/quickwit-serve/src/elastic_search_api/rest_handler.rs index aab5f5f70ab..2bf8737fb10 100644 --- a/quickwit/quickwit-serve/src/elastic_search_api/rest_handler.rs +++ b/quickwit/quickwit-serve/src/elastic_search_api/rest_handler.rs @@ -55,18 +55,20 @@ pub fn es_compat_info_handler( super::filter::elastic_info_filter() .and(with_arg(build_info)) .and(with_arg(config)) - .then(|build_info: &'static BuildInfo, config: Arc| async move { - warp::reply::json(&json!({ - "name" : config.node_id, - "cluster_name" : config.cluster_id, - "version" : { - "distribution" : "quickwit", - "number" : build_info.version, - "build_hash" : build_info.commit_hash, - "build_date" : build_info.build_date, - } - })) - }) + .then( + |build_info: &'static BuildInfo, config: Arc| async move { + warp::reply::json(&json!({ + "name" : config.node_id, + "cluster_name" : config.cluster_id, + "version" : { + "distribution" : "quickwit", + "number" : build_info.version, + "build_hash" : build_info.commit_hash, + "build_date" : build_info.build_date, + } + })) + }, + ) } /// GET or POST _elastic/_search diff --git a/quickwit/quickwit-serve/src/node_info_handler.rs b/quickwit/quickwit-serve/src/node_info_handler.rs index 758a2c9d98d..c99957acf1d 100644 --- a/quickwit/quickwit-serve/src/node_info_handler.rs +++ b/quickwit/quickwit-serve/src/node_info_handler.rs @@ -23,19 +23,15 @@ use quickwit_config::QuickwitConfig; use serde_json::json; use warp::{Filter, Rejection}; -use crate::{with_arg, BuildInfo, RuntimeInfo}; use crate::elastic_search_api::es_compat_info_handler; +use crate::{with_arg, BuildInfo, RuntimeInfo}; -// TODO: make the models utoipa compatible and register +// TODO: make the models utoipa compatible and register // all endpoints in the docs here. #[derive(utoipa::OpenApi)] -#[openapi(paths( - node_version_handler, - node_config_handler, -))] +#[openapi(paths(node_version_handler, node_config_handler,))] pub struct NodeInfoApi; - pub fn node_info_handler( build_info: &'static BuildInfo, runtime_info: &'static RuntimeInfo, @@ -130,7 +126,10 @@ mod tests { }); assert_json_include!(actual: resp_json, expected: expected_response_json); - let resp = warp::test::request().path("/_elastic").reply(&handler).await; + let resp = warp::test::request() + .path("/_elastic") + .reply(&handler) + .await; assert_eq!(resp.status(), 200); let resp_json: JsonValue = serde_json::from_slice(resp.body()).unwrap(); let expected_response_json = serde_json::json!({ diff --git a/quickwit/quickwit-serve/src/openapi.rs b/quickwit/quickwit-serve/src/openapi.rs index bb3b6bbbd90..182ad842e46 100644 --- a/quickwit/quickwit-serve/src/openapi.rs +++ b/quickwit/quickwit-serve/src/openapi.rs @@ -86,7 +86,8 @@ pub fn build_docs() -> utoipa::openapi::OpenApi { docs_base.merge_components_and_paths(IndexingApi::openapi().with_path_prefix("/api/v1")); docs_base.merge_components_and_paths(IngestApi::openapi().with_path_prefix("/api/v1")); docs_base.merge_components_and_paths(SearchApi::openapi().with_path_prefix("/api/v1")); - docs_base.merge_components_and_paths(ElasticCompatibleApi::openapi().with_path_prefix("/api/v1")); + docs_base + .merge_components_and_paths(ElasticCompatibleApi::openapi().with_path_prefix("/api/v1")); docs_base.merge_components_and_paths(NodeInfoApi::openapi().with_path_prefix("/api/v1")); // Schemas