Skip to content

Commit

Permalink
chore(lint): fix lint
Browse files Browse the repository at this point in the history
Signed-off-by: Abhilash Shetty <[email protected]>
  • Loading branch information
abhilashshetty04 committed Jan 7, 2024
1 parent 02aad16 commit f1f869e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
13 changes: 0 additions & 13 deletions io-engine/src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use tonic::{Request, Response, Status};
use crate::{
bdev_api::BdevError,
core::{CoreError, Reactor, VerboseError},
grpc::v1::{pool::PoolService, replica::ReplicaService},
};

impl From<BdevError> for tonic::Status {
Expand Down Expand Up @@ -130,18 +129,6 @@ pub(crate) trait RWSerializer<F, T> {
async fn shared(&self, ctx: GrpcClientContext, f: F) -> Result<T, Status>;
}

/// Trait allows Service implementing it to lock Pool and Replica Service.
#[async_trait::async_trait]
pub(crate) trait SvcLocker<F, T> {
async fn svc_lock(
&self,
ctx: GrpcClientContext,
pool_svc: PoolService,
replica_svc: ReplicaService,
f: F,
) -> Result<T, Status>;
}

pub type GrpcResult<T> = std::result::Result<Response<T>, Status>;

/// call the given future within the context of the reactor on the first core
Expand Down
20 changes: 6 additions & 14 deletions io-engine/src/grpc/v1/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
GrpcClientContext,
GrpcResult,
RWSerializer,
SvcLocker,
Serializer,
},
lvs::Lvs,
};
Expand All @@ -30,20 +30,14 @@ pub struct StatsService {
}

#[async_trait::async_trait]
impl<F, T> SvcLocker<F, T> for StatsService
impl<F, T> Serializer<F, T> for StatsService
where
T: Send + 'static,
F: core::future::Future<Output = Result<T, Status>> + Send + 'static,
{
async fn svc_lock(
&self,
ctx: GrpcClientContext,
pool_svc: PoolService,
replica_svc: ReplicaService,
f: F,
) -> Result<T, Status> {
let pool_context = pool_svc.client_context.write().await;
let replica_context = replica_svc.client_context.write().await;
async fn locked(&self, ctx: GrpcClientContext, f: F) -> Result<T, Status> {
let pool_context = self.pool_svc.client_context.write().await;
let replica_context = self.replica_svc.client_context.write().await;
if let Some(c) = pool_context.as_ref() {
warn!("{}: gRPC method timed out, args: {}", c.id, c.args);
}
Expand Down Expand Up @@ -143,10 +137,8 @@ impl StatsRpc for StatsService {
}
#[named]
async fn reset_io_stats(&self, request: Request<()>) -> GrpcResult<()> {
self.svc_lock(
self.locked(
GrpcClientContext::new(&request, function_name!()),
self.pool_svc.clone(),
self.replica_svc.clone(),
async move {
let rx = rpc_submit::<_, _, CoreError>(async move {
if let Some(bdev) = UntypedBdev::bdev_first() {
Expand Down

0 comments on commit f1f869e

Please sign in to comment.