Skip to content

Commit 53027ca

Browse files
committed
Remove PdRequestContext
Signed-off-by: Nick Cameron <nrc@ncameron.org>
1 parent 477ac94 commit 53027ca

File tree

2 files changed

+13
-36
lines changed

2 files changed

+13
-36
lines changed

src/rpc/pd/client.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ use kvproto::{metapb, pdpb, pdpb::PdClient as RpcClient};
1414

1515
use crate::{
1616
rpc::{
17+
context::RequestContext,
1718
pd::{
18-
context::{request_context, PdRequestContext},
19-
leader::LeaderClient,
20-
request::Request,
21-
PdTimestamp, Region, RegionId, Store, StoreId,
19+
context::request_context, leader::LeaderClient, request::Request, PdTimestamp, Region,
20+
RegionId, Store, StoreId,
2221
},
2322
security::SecurityManager,
2423
},
@@ -136,7 +135,7 @@ impl PdClient {
136135

137136
fn execute<Executor, Resp, RpcFuture>(
138137
&self,
139-
mut context: PdRequestContext<Executor>,
138+
mut context: RequestContext<Executor>,
140139
) -> impl Future<Output = Result<Resp>>
141140
where
142141
Executor: FnMut(&RpcClient, CallOption) -> ::grpcio::Result<RpcFuture> + Send + 'static,

src/rpc/pd/context.rs

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,22 @@
11
// Copyright 2018 TiKV Project Authors. Licensed under Apache-2.0.
22

3-
use std::ops::{Deref, DerefMut};
4-
53
use lazy_static::*;
64
use prometheus::*;
75

86
use crate::rpc::context::RequestContext;
97

10-
pub struct PdRequestContext<Executor> {
11-
target: RequestContext<Executor>,
12-
}
13-
14-
impl<Executor> Deref for PdRequestContext<Executor> {
15-
type Target = RequestContext<Executor>;
16-
17-
fn deref(&self) -> &Self::Target {
18-
&self.target
19-
}
20-
}
21-
22-
impl<Executor> DerefMut for PdRequestContext<Executor> {
23-
fn deref_mut(&mut self) -> &mut Self::Target {
24-
&mut self.target
25-
}
26-
}
27-
288
pub fn request_context<Executor>(
299
cmd: &'static str,
3010
executor: Executor,
31-
) -> PdRequestContext<Executor> {
32-
PdRequestContext {
33-
target: RequestContext::new(
34-
cmd,
35-
&PD_REQUEST_DURATION_HISTOGRAM_VEC,
36-
&PD_REQUEST_COUNTER_VEC,
37-
&PD_FAILED_REQUEST_DURATION_HISTOGRAM_VEC,
38-
&PD_FAILED_REQUEST_COUNTER_VEC,
39-
executor,
40-
),
41-
}
11+
) -> RequestContext<Executor> {
12+
RequestContext::new(
13+
cmd,
14+
&PD_REQUEST_DURATION_HISTOGRAM_VEC,
15+
&PD_REQUEST_COUNTER_VEC,
16+
&PD_FAILED_REQUEST_DURATION_HISTOGRAM_VEC,
17+
&PD_FAILED_REQUEST_COUNTER_VEC,
18+
executor,
19+
)
4220
}
4321

4422
pub fn observe_tso_batch(batch_size: usize) -> u32 {

0 commit comments

Comments
 (0)