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

Remove unused deps from graph-server-metrics #4224

Merged
merged 2 commits into from
Dec 5, 2022
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: 0 additions & 3 deletions Cargo.lock

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

12 changes: 0 additions & 12 deletions graph/src/components/server/metrics.rs

This file was deleted.

3 changes: 0 additions & 3 deletions graph/src/components/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ pub mod subscription;

/// Component for the index node server.
pub mod index_node;

/// Components for the Prometheus metrics server.
pub mod metrics;
1 change: 0 additions & 1 deletion graph/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ pub mod prelude {
PrometheusError, Registry,
};
pub use crate::components::server::index_node::IndexNodeServer;
pub use crate::components::server::metrics::MetricsServer;
pub use crate::components::server::query::GraphQLServer;
pub use crate::components::server::subscription::SubscriptionServer;
pub use crate::components::store::{
Expand Down
6 changes: 3 additions & 3 deletions node/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,12 +568,12 @@ async fn main() {
.compat(),
);

graph::spawn(
graph::spawn(async move {
metrics_server
.serve(metrics_port)
.await
.expect("Failed to start metrics server")
.compat(),
);
});
};

graph::spawn(launch_services(logger.clone(), env_vars.cheap_clone()));
Expand Down
3 changes: 0 additions & 3 deletions server/metrics/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,4 @@ edition.workspace = true

[dependencies]
graph = { path = "../../graph" }
http = "0.2"
hyper = { version = "0.14", features = ["server"] }
lazy_static = "1.2.0"
serde = "1.0"
15 changes: 6 additions & 9 deletions server/metrics/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use std::net::{Ipv4Addr, SocketAddrV4};
use std::sync::Arc;

use anyhow::Error;
use graph::prometheus::{Encoder, Registry, TextEncoder};
use hyper::header::{ACCESS_CONTROL_ALLOW_ORIGIN, CONTENT_TYPE};
use hyper::service::{make_service_fn, service_fn};
use hyper::{Body, Response, Server};
use thiserror::Error;

use graph::prelude::{MetricsServer as MetricsServerTrait, *};
use graph::prelude::*;
use graph::prometheus::{Encoder, Registry, TextEncoder};

/// Errors that may occur when starting the server.
#[derive(Debug, Error)]
Expand All @@ -30,15 +30,12 @@ impl PrometheusMetricsServer {
registry,
}
}
}

impl MetricsServerTrait for PrometheusMetricsServer {
type ServeError = PrometheusMetricsServeError;

fn serve(
/// Creates a new Tokio task that, when spawned, brings up the index node server.
pub async fn serve(
&mut self,
port: u16,
) -> Result<Box<dyn Future<Item = (), Error = ()> + Send>, Self::ServeError> {
) -> Result<Result<(), ()>, PrometheusMetricsServeError> {
let logger = self.logger.clone();

info!(
Expand Down Expand Up @@ -73,6 +70,6 @@ impl MetricsServerTrait for PrometheusMetricsServer {
.serve(new_service)
.map_err(move |e| error!(logger, "Metrics server error"; "error" => format!("{}", e)));

Ok(Box::new(task.compat()))
Ok(task.await)
}
}