Skip to content

Commit

Permalink
Removing dependencies (#3782)
Browse files Browse the repository at this point in the history
* Removing deps from quickwit-common -> {warp, utoipa}

* Removing unused dependencies and moving utopia/warp out of quickwit-common
  • Loading branch information
fulmicoton authored Aug 31, 2023
1 parent bf98578 commit 5e69822
Show file tree
Hide file tree
Showing 10 changed files with 49 additions and 41 deletions.
6 changes: 0 additions & 6 deletions quickwit/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions quickwit/quickwit-aws/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ aws-smithy-async = { workspace = true }
aws-smithy-client = { workspace = true }
aws-types = { workspace = true }

anyhow = { workspace = true }
async-trait = { workspace = true }
futures = { workspace = true }
hyper = { workspace = true }
hyper-rustls = { workspace = true }
once_cell = { workspace = true }
rand = { workspace = true }
thiserror = { workspace = true }
tokio = { workspace = true }
tower = { workspace = true }
tracing = { workspace = true }
Expand Down
2 changes: 0 additions & 2 deletions quickwit/quickwit-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ tokio-stream = { workspace = true }
tonic = { workspace = true }
tower = { workspace = true }
tracing = { workspace = true }
utoipa = { workspace = true }
warp = { workspace = true }

[features]
testsuite = []
Expand Down
22 changes: 1 addition & 21 deletions quickwit/quickwit-common/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,27 +156,7 @@ impl Drop for GaugeGuard {
}
}

#[derive(utoipa::OpenApi)]
#[openapi(paths(metrics_handler))]
/// Endpoints which are weirdly tied to another crate with no
/// other bits of information attached.
///
/// If a crate plans to encompass different schemas, handlers, etc...
/// Then it should have it's own specific API group.
pub struct MetricsApi;

#[utoipa::path(
get,
tag = "Get Metrics",
path = "/",
responses(
(status = 200, description = "Successfully fetched metrics.", body = String),
),
)]
/// Get Node Metrics
///
/// These are in the form of prometheus metrics.
pub fn metrics_handler() -> impl warp::Reply {
pub fn metrics_text_payload() -> String {
let metric_families = prometheus::gather();
let mut buffer = Vec::new();
let encoder = TextEncoder::new();
Expand Down
6 changes: 2 additions & 4 deletions quickwit/quickwit-control-plane/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ documentation = "https://quickwit.io/docs/"
[dependencies]
anyhow = { workspace = true }
async-trait = { workspace = true }
chitchat = { workspace = true }
dyn-clone = { workspace = true }
http = { workspace = true }
hyper = { workspace = true }
Expand All @@ -28,13 +27,10 @@ tokio-stream = { workspace = true }
tonic = { workspace = true }
tower = { workspace = true }
tracing = { workspace = true }
utoipa = { workspace = true }

quickwit-actors = { workspace = true }
quickwit-cluster = { workspace = true }
quickwit-common = { workspace = true }
quickwit-config = { workspace = true }
quickwit-indexing = { workspace = true }
quickwit-metastore = { workspace = true }
quickwit-proto = { workspace = true }

Expand All @@ -46,6 +42,8 @@ rand = { workspace = true }

quickwit-actors = { workspace = true, features = ["testsuite"] }
quickwit-cluster = { workspace = true, features = ["testsuite"] }
chitchat = { workspace = true }
quickwit-indexing = { workspace = true }
quickwit-common = { workspace = true, features = ["testsuite"] }
quickwit-config = { workspace = true, features = ["testsuite"] }
quickwit-metastore = { workspace = true, features = ["testsuite"] }
Expand Down
1 change: 0 additions & 1 deletion quickwit/quickwit-search/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ opentelemetry = { workspace = true }
ulid = { workspace = true }
utoipa = { workspace = true }

quickwit-cluster = { workspace = true }
quickwit-common = { workspace = true }
quickwit-config = { workspace = true }
quickwit-directories = { workspace = true }
Expand Down
1 change: 1 addition & 0 deletions quickwit/quickwit-serve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ mod index_api;
mod indexing_api;
mod ingest_api;
mod json_api_response;
mod metrics_api;
mod node_info_handler;
mod openapi;
mod search_api;
Expand Down
42 changes: 42 additions & 0 deletions quickwit/quickwit-serve/src/metrics_api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright (C) 2023 Quickwit, Inc.
//
// Quickwit is offered under the AGPL v3.0 and as commercial software.
// For commercial licensing, contact us at [email protected].
//
// AGPL:
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

#[derive(utoipa::OpenApi)]
#[openapi(paths(metrics_handler))]
/// Endpoints which are weirdly tied to another crate with no
/// other bits of information attached.
///
/// If a crate plans to encompass different schemas, handlers, etc...
/// Then it should have it's own specific API group.
pub struct MetricsApi;

#[utoipa::path(
get,
tag = "Get Metrics",
path = "/",
responses(
(status = 200, description = "Successfully fetched metrics.", body = String),
),
)]
/// Get Node Metrics
///
/// These are in the form of prometheus metrics.
pub fn metrics_handler() -> impl warp::Reply {
quickwit_common::metrics::metrics_text_payload()
}
2 changes: 1 addition & 1 deletion quickwit/quickwit-serve/src/openapi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

use std::mem;

use quickwit_common::metrics::MetricsApi;
use quickwit_config::ConfigApiSchemas;
use quickwit_doc_mapper::DocMapperApiSchemas;
use quickwit_indexing::IndexingApiSchemas;
Expand All @@ -35,6 +34,7 @@ use crate::health_check_api::HealthCheckApi;
use crate::index_api::IndexApi;
use crate::indexing_api::IndexingApi;
use crate::ingest_api::{IngestApi, IngestApiSchemas};
use crate::metrics_api::MetricsApi;
use crate::node_info_handler::NodeInfoApi;
use crate::search_api::SearchApi;

Expand Down
6 changes: 2 additions & 4 deletions quickwit/quickwit-serve/src/rest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ use std::sync::Arc;

use hyper::http::HeaderValue;
use hyper::{http, Method};
use quickwit_common::metrics;
use quickwit_common::tower::BoxFutureInfaillible;
use quickwit_proto::ServiceErrorCode;
use tower::make::Shared;
Expand All @@ -41,6 +40,7 @@ use crate::index_api::index_management_handlers;
use crate::indexing_api::indexing_get_handler;
use crate::ingest_api::ingest_api_handlers;
use crate::json_api_response::{ApiError, JsonApiResponse};
use crate::metrics_api::metrics_handler;
use crate::node_info_handler::node_info_handler;
use crate::search_api::{search_get_handler, search_post_handler, search_stream_handler};
use crate::ui_handler::ui_handler;
Expand Down Expand Up @@ -83,9 +83,7 @@ pub(crate) async fn start_rest_server(
);

// `/metrics` route.
let metrics_routes = warp::path("metrics")
.and(warp::get())
.map(metrics::metrics_handler);
let metrics_routes = warp::path("metrics").and(warp::get()).map(metrics_handler);

let ingest_service = quickwit_services.ingest_service.clone();

Expand Down

0 comments on commit 5e69822

Please sign in to comment.