Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

box warp routes #5540

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions quickwit/quickwit-codegen/example/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ where S: Service<R>
}

#[derive(Debug, Clone, Default)]
#[allow(dead_code)]
struct CounterLayer {
counter: Arc<AtomicUsize>,
}
Expand All @@ -77,6 +78,7 @@ impl<S> Layer<S> for CounterLayer {
}
}

#[allow(dead_code)]
fn spawn_ping_response_stream(
mut request_stream: ServiceStream<PingRequest>,
) -> ServiceStream<HelloResult<PingResponse>> {
Expand Down Expand Up @@ -114,6 +116,7 @@ fn spawn_ping_response_stream(
}

#[derive(Debug, Clone, Default)]
#[allow(dead_code)]
struct HelloImpl {
delay: Duration,
}
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-serve/src/cluster_api/rest_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub fn cluster_handler(
.and(extract_format_from_qs())
.map(into_rest_api_response)
.recover(recover_fn)
.boxed()
}

#[utoipa::path(
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-serve/src/delete_task_api/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ pub fn delete_task_api_handlers(
get_delete_tasks_handler(metastore.clone())
.or(post_delete_tasks_handler(metastore.clone()))
.recover(recover_fn)
.boxed()
}

pub fn get_delete_tasks_handler(
Expand Down
2 changes: 1 addition & 1 deletion quickwit/quickwit-serve/src/developer_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ pub(crate) fn developer_api_routes(
warp::path!("api" / "developer" / ..)
.and(
debug_handler(cluster.clone())
.or(log_level_handler(env_filter_reload_fn.clone()))
.or(log_level_handler(env_filter_reload_fn.clone()).boxed())
.or(pprof_handlers()),
)
.recover(recover_fn)
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-serve/src/elasticsearch_api/bulk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ pub fn es_compat_index_bulk_handler(
.and(extract_format_from_qs())
.map(make_elastic_api_response)
.recover(recover_fn)
.boxed()
}

async fn elastic_ingest_bulk(
Expand Down
3 changes: 3 additions & 0 deletions quickwit/quickwit-serve/src/elasticsearch_api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ pub fn elastic_api_handlers(
ingest_service.clone(),
ingest_router.clone(),
))
.boxed()
.or(es_compat_index_bulk_handler(ingest_service, ingest_router))
.or(es_compat_index_search_handler(search_service.clone()))
.or(es_compat_index_count_handler(search_service.clone()))
Expand All @@ -75,13 +76,15 @@ pub fn elastic_api_handlers(
.or(es_compat_index_field_capabilities_handler(
search_service.clone(),
))
.boxed()
.or(es_compat_index_stats_handler(metastore.clone()))
.or(es_compat_delete_index_handler(index_service))
.or(es_compat_stats_handler(metastore.clone()))
.or(es_compat_index_cat_indices_handler(metastore.clone()))
.or(es_compat_cat_indices_handler(metastore.clone()))
.or(es_compat_resolve_index_handler(metastore.clone()))
.recover(recover_fn)
.boxed()
// Register newly created handlers here.
}

Expand Down
11 changes: 11 additions & 0 deletions quickwit/quickwit-serve/src/elasticsearch_api/rest_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ pub fn es_compat_cluster_info_handler(
}))
},
)
.boxed()
}

/// GET or POST _elastic/_search
Expand Down Expand Up @@ -135,6 +136,7 @@ pub fn es_compat_delete_index_handler(
.and(with_arg(index_service))
.then(es_compat_delete_index)
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
.boxed()
}

/// GET _elastic/_stats
Expand All @@ -146,6 +148,7 @@ pub fn es_compat_stats_handler(
.then(es_compat_stats)
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
.recover(recover_fn)
.boxed()
}

/// GET _elastic/{index}/_stats
Expand All @@ -157,6 +160,7 @@ pub fn es_compat_index_stats_handler(
.then(es_compat_index_stats)
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
.recover(recover_fn)
.boxed()
}

/// GET _elastic/_cat/indices
Expand All @@ -168,6 +172,7 @@ pub fn es_compat_cat_indices_handler(
.then(es_compat_cat_indices)
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
.recover(recover_fn)
.boxed()
}

/// GET _elastic/_cat/indices/{index}
Expand All @@ -179,6 +184,7 @@ pub fn es_compat_index_cat_indices_handler(
.then(es_compat_index_cat_indices)
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
.recover(recover_fn)
.boxed()
}

/// GET _elastic/_resolve/index/{index}
Expand All @@ -189,6 +195,7 @@ pub fn es_compat_resolve_index_handler(
.and(with_arg(metastore_service))
.then(es_compat_resolve_index)
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
.boxed()
}

/// GET or POST _elastic/{index}/_search
Expand All @@ -200,6 +207,7 @@ pub fn es_compat_index_search_handler(
.then(es_compat_index_search)
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
.recover(recover_fn)
.boxed()
}

/// GET or POST _elastic/{index}/_count
Expand All @@ -211,6 +219,7 @@ pub fn es_compat_index_count_handler(
.then(es_compat_index_count)
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
.recover(recover_fn)
.boxed()
}

/// POST _elastic/_msearch
Expand All @@ -228,6 +237,7 @@ pub fn es_compat_index_multi_search_handler(
RestApiResponse::new(&result, status_code, BodyFormat::default())
})
.recover(recover_fn)
.boxed()
}

/// GET or POST _elastic/_search/scroll
Expand All @@ -239,6 +249,7 @@ pub fn es_compat_scroll_handler(
.then(es_scroll)
.map(|result| make_elastic_api_response(result, BodyFormat::default()))
.recover(recover_fn)
.boxed()
}

fn build_request_for_es_api(
Expand Down
21 changes: 21 additions & 0 deletions quickwit/quickwit-serve/src/index_api/rest_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,26 @@ pub fn index_management_handlers(
.or(update_index_handler(index_service.metastore()))
.or(clear_index_handler(index_service.clone()))
.or(delete_index_handler(index_service.clone()))
.boxed()
// Splits handlers
.or(list_splits_handler(index_service.metastore()))
.or(describe_index_handler(index_service.metastore()))
.or(mark_splits_for_deletion_handler(index_service.metastore()))
.boxed()
// Sources handlers.
.or(reset_source_checkpoint_handler(index_service.metastore()))
.or(toggle_source_handler(index_service.metastore()))
.or(create_source_handler(index_service.clone()))
.or(get_source_handler(index_service.metastore()))
.or(delete_source_handler(index_service.metastore()))
.or(get_source_shards_handler(index_service.metastore()))
.boxed()
// Tokenizer handlers.
.or(analyze_request_handler())
// Parse query into query AST handler.
.or(parse_query_request_handler())
.recover(recover_fn)
.boxed()
}

fn json_body<T: DeserializeOwned + Send>(
Expand All @@ -127,6 +131,7 @@ pub fn get_index_metadata_handler(
.then(get_index_metadata)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

async fn get_index_metadata(
Expand Down Expand Up @@ -163,6 +168,7 @@ fn list_indexes_metadata_handler(
.then(list_indexes_metadata)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

/// Describes an index with its main information and statistics.
Expand Down Expand Up @@ -260,6 +266,7 @@ fn describe_index_handler(
.then(describe_index)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

/// This struct represents the QueryString passed to
Expand Down Expand Up @@ -377,6 +384,7 @@ fn list_splits_handler(
.then(list_splits)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[derive(Deserialize, utoipa::ToSchema)]
Expand Down Expand Up @@ -433,6 +441,7 @@ fn mark_splits_for_deletion_handler(
.then(mark_splits_for_deletion)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[utoipa::path(
Expand Down Expand Up @@ -496,6 +505,7 @@ fn create_index_handler(
.map(log_failure("failed to create index"))
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[utoipa::path(
Expand Down Expand Up @@ -544,6 +554,7 @@ fn update_index_handler(
.map(log_failure("failed to update index"))
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[utoipa::path(
Expand Down Expand Up @@ -606,6 +617,7 @@ fn clear_index_handler(
.then(clear_index)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[utoipa::path(
Expand Down Expand Up @@ -646,6 +658,7 @@ fn delete_index_handler(
.then(delete_index)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[utoipa::path(
Expand Down Expand Up @@ -686,6 +699,7 @@ fn create_source_handler(
.map(log_failure("failed to create source"))
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[utoipa::path(
Expand Down Expand Up @@ -741,6 +755,7 @@ fn get_source_handler(
.then(get_source)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

async fn get_source(
Expand Down Expand Up @@ -774,6 +789,7 @@ fn reset_source_checkpoint_handler(
.then(reset_source_checkpoint)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[utoipa::path(
Expand Down Expand Up @@ -821,6 +837,7 @@ fn toggle_source_handler(
.then(toggle_source)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[derive(Deserialize, utoipa::ToSchema)]
Expand Down Expand Up @@ -880,6 +897,7 @@ fn delete_source_handler(
.then(delete_source)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

#[utoipa::path(
Expand Down Expand Up @@ -930,6 +948,7 @@ fn get_source_shards_handler(
.then(get_source_shards)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

async fn get_source_shards(
Expand Down Expand Up @@ -982,6 +1001,7 @@ fn analyze_request_handler() -> impl Filter<Extract = (impl warp::Reply,), Error
.then(analyze_request)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

/// Analyzes text with given tokenizer config and returns the list of tokens.
Expand Down Expand Up @@ -1027,6 +1047,7 @@ fn parse_query_request_handler(
.then(parse_query_request)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

/// Analyzes text with given tokenizer config and returns the list of tokens.
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-serve/src/indexing_api/rest_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ pub fn indexing_get_handler(
.and(extract_format_from_qs())
.map(into_rest_api_response)
.recover(recover_fn)
.boxed()
}
4 changes: 4 additions & 0 deletions quickwit/quickwit-serve/src/ingest_api/rest_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub(crate) fn ingest_api_handlers(
ingest_handler(ingest_service.clone(), config.clone())
.or(tail_handler(ingest_service))
.or(ingest_v2_handler(ingest_router, config))
.boxed()
}

fn ingest_filter(
Expand All @@ -96,6 +97,7 @@ fn ingest_handler(
.and(with_arg(ingest_service))
.then(ingest)
.map(|result| into_rest_api_response(result, BodyFormat::default()))
.boxed()
}

fn ingest_v2_filter(
Expand All @@ -121,6 +123,7 @@ fn ingest_v2_handler(
.then(ingest_v2)
.and(with_arg(BodyFormat::default()))
.map(into_rest_api_response)
.boxed()
}

async fn ingest_v2(
Expand Down Expand Up @@ -223,6 +226,7 @@ pub fn tail_handler(
.then(tail_endpoint)
.and(extract_format_from_qs())
.map(into_rest_api_response)
.boxed()
}

fn tail_filter() -> impl Filter<Extract = (String,), Error = Rejection> + Clone {
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-serve/src/jaeger_api/rest_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub(crate) fn jaeger_api_handlers(
.or(jaeger_traces_search_handler(jaeger_service_opt.clone()))
.or(jaeger_traces_handler(jaeger_service_opt.clone()))
.recover(recover_fn)
.boxed()
}

fn jaeger_api_path_filter() -> impl Filter<Extract = (Vec<String>,), Error = Rejection> + Clone {
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-serve/src/node_info_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub fn node_info_handler(
node_version_handler(build_info, runtime_info)
.or(node_config_handler(config))
.recover(recover_fn)
.boxed()
}

#[utoipa::path(get, tag = "Node Info", path = "/version")]
Expand Down
Loading
Loading