Skip to content

Commit

Permalink
fix(middleware): change mod visibility to pass build.
Browse files Browse the repository at this point in the history
  • Loading branch information
andysim3d committed Sep 26, 2024
1 parent 83ba4ef commit 8b8692b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 12 deletions.
7 changes: 5 additions & 2 deletions crates/pool/src/server/remote/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use async_trait::async_trait;
use futures_util::StreamExt;
use rundler_task::{
grpc::{grpc_metrics::HttpMethodExtractor, protos::from_bytes},
metrics::{MetricsLayer, RequestMethodNameInfo},
metrics::MetricsLayer,
};
use rundler_types::{
chain::ChainSpec,
Expand Down Expand Up @@ -81,7 +81,10 @@ pub(crate) async fn spawn_remote_mempool_server(
.set_serving::<OpPoolServer<OpPoolImpl>>()
.await;

let metrics_layer = MetricsLayer::<HttpMethodExtractor, http::Request>::new("op_pool_service".to_string(), "http-grpc".to_string());
let metrics_layer = MetricsLayer::<HttpMethodExtractor, http::Request>::new(
"op_pool_service".to_string(),
"http-grpc".to_string(),
);
let handle = tokio::spawn(async move {
Server::builder()
.layer(metrics_layer)
Expand Down
2 changes: 1 addition & 1 deletion crates/provider/src/traits/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use rundler_types::task::traits::RequestExtractor;
use alloy_json_rpc::RequestPacket;

#[derive(Clone, Copy)]
struct AlloyMethodExtractor;
pub struct AlloyMethodExtractor;

impl RequestExtractor<RequestPacket> for RPCMethodExtractor {
fn get_method_name(req: &RequestPacket) -> String {
Expand Down
4 changes: 2 additions & 2 deletions crates/rpc/src/rpc_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ use jsonrpsee::types::Request;
use rundler_types::task::traits::RequestExtractor;

#[derive(Copy, Clone)]
struct RPCMethodExtractor;
pub struct RPCMethodExtractor;

impl RequestExtractor<Request<'static>> for RPCMethodExtractor {
fn get_method_name(req: & Request<'static>) -> String {
fn get_method_name(req: &Request<'static>) -> String {
req.method_name().to_string()
}
}
13 changes: 8 additions & 5 deletions crates/rpc/src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use std::{net::SocketAddr, sync::Arc, time::Duration};
use anyhow::{bail, Context};
use async_trait::async_trait;
use jsonrpsee::{
server::{middleware::http::ProxyGetRequestLayer, RpcServiceBuilder, ServerBuilder}, types::Request, RpcModule
server::{middleware::http::ProxyGetRequestLayer, RpcServiceBuilder, ServerBuilder},
types::Request,
RpcModule,
};
use rundler_provider::{EntryPointProvider, Provider};
use rundler_sim::{
Expand All @@ -42,10 +44,9 @@ use crate::{
EthApiSettings, UserOperationEventProviderV0_6, UserOperationEventProviderV0_7,
},
health::{HealthChecker, SystemApiServer},
rpc_metrics,
rpc_metrics::RPCMethodExtractor,
rundler::{RundlerApi, RundlerApiServer, Settings as RundlerApiSettings},
types::ApiNamespace,
rpc_metrics::RPCMethodExtractor,
};

/// RPC server arguments.
Expand Down Expand Up @@ -187,8 +188,10 @@ where
.layer(ProxyGetRequestLayer::new("/health", "system_health")?)
.timeout(self.args.rpc_timeout);

let rpc_metric_middleware =
MetricsLayer::<RPCMethodExtractor, Request>::new("rundler-eth-service".to_string(), "rpc".to_string());
let rpc_metric_middleware = MetricsLayer::<RPCMethodExtractor, Request<'static>>::new(
"rundler-eth-service".to_string(),
"rpc".to_string(),
);

let server = ServerBuilder::default()
.set_http_middleware(http_middleware)
Expand Down
4 changes: 2 additions & 2 deletions crates/task/src/grpc/grpc_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
use rundler_types::task::traits::RequestExtractor;
use tonic::codegen::http;

/// http request method extractor.
/// http request method extractor.
#[derive(Copy, Clone)]
struct HttpMethodExtractor;
pub struct HttpMethodExtractor;

impl<Body> RequestExtractor<http::Request<Body>> for HttpMethodExtractor {
fn get_method_name(req: &http::Request<Body>) -> String {
Expand Down
1 change: 1 addition & 0 deletions crates/task/src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

//! Utilities for working with gRPC
/// grpc method extractor implmentation.
pub mod grpc_metrics;
#[allow(non_snake_case)]
pub mod protos;
4 changes: 4 additions & 0 deletions crates/types/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@
// If not, see https://www.gnu.org/licenses/.

//! Rundler task traits.
//!
//! This module contains traits related to Rundler tasks.
/// method extractor trait.
pub mod traits;

0 comments on commit 8b8692b

Please sign in to comment.