Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
evanxg852000 committed Jun 29, 2023
1 parent 03797e5 commit f86c349
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 30 deletions.
11 changes: 4 additions & 7 deletions quickwit/quickwit-serve/src/elastic_search_api/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Extract = (), Error = Rejection> + Clone {
pub(crate) fn elastic_info_filter() -> impl Filter<Extract = (), Error = Rejection> + 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")]
Expand Down
4 changes: 2 additions & 2 deletions quickwit/quickwit-serve/src/elastic_search_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand Down
26 changes: 14 additions & 12 deletions quickwit/quickwit-serve/src/elastic_search_api/rest_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<QuickwitConfig>| 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<QuickwitConfig>| 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
Expand Down
15 changes: 7 additions & 8 deletions quickwit/quickwit-serve/src/node_info_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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!({
Expand Down
3 changes: 2 additions & 1 deletion quickwit/quickwit-serve/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f86c349

Please sign in to comment.