debug: Parameterize debug service
ref tikv/tikv#12849
Parameterize debug service
// Copyright 2017 TiKV Project Authors. Licensed under Apache-2.0.
use engine_rocks::RocksEngine;
-use engine_traits::{Engines, MiscExt, RaftEngine};
+use engine_traits::{Engines, KvEngine, MiscExt, RaftEngine};
use futures::{
channel::oneshot,
future::{Future, FutureExt, TryFutureExt},
@@ -53,25 +53,27 @@ fn error_to_grpc_error(tag: &'static str, e: Error) -> GrpcError {
/// Service handles the RPC messages for the `Debug` service.
#[derive(Clone)]
-pub struct Service<ER: RaftEngine, T: RaftStoreRouter<RocksEngine>> {
+pub struct Service<ER: RaftEngine, EK: KvEngine, T: RaftStoreRouter<EK>> {
pool: Handle,
debugger: Debugger<ER>,
raft_router: T,
+ _phantom: std::marker::PhantomData<EK>,
}
-impl<ER: RaftEngine, T: RaftStoreRouter<RocksEngine>> Service<ER, T> {
+impl<ER: RaftEngine, EK: KvEngine, T: RaftStoreRouter<EK>> Service<ER, EK, T> {
/// Constructs a new `Service` with `Engines`, a `RaftStoreRouter` and a `GcWorker`.
pub fn new(
engines: Engines<RocksEngine, ER>,
pool: Handle,
raft_router: T,
cfg_controller: ConfigController,
- ) -> Service<ER, T> {
+ ) -> Service<ER, EK, T> {
let debugger = Debugger::new(engines, cfg_controller);
Service {
pool,
debugger,
raft_router,
+ _phantom: Default::default(),
}
}
@@ -96,7 +98,9 @@ impl<ER: RaftEngine, T: RaftStoreRouter<RocksEngine>> Service<ER, T> {
}
}
-impl<ER: RaftEngine, T: RaftStoreRouter<RocksEngine> + 'static> debugpb::Debug for Service<ER, T> {
+impl<ER: RaftEngine, EK: KvEngine, T: RaftStoreRouter<EK> + 'static> debugpb::Debug
+ for Service<ER, EK, T>
+{
fn get(&mut self, ctx: RpcContext<'_>, mut req: GetRequest, sink: UnarySink<GetResponse>) {
const TAG: &str = "debug_get";
@@ -532,7 +536,7 @@ impl<ER: RaftEngine, T: RaftStoreRouter<RocksEngine> + 'static> debugpb::Debug f
}
}
-fn region_detail<T: RaftStoreRouter<RocksEngine>>(
+fn region_detail<EK: KvEngine, T: RaftStoreRouter<EK>>(
raft_router: T,
region_id: u64,
store_id: u64,
@@ -573,7 +577,7 @@ fn region_detail<T: RaftStoreRouter<RocksEngine>>(
}
}
-fn consistency_check<T: RaftStoreRouter<RocksEngine>>(
+fn consistency_check<EK: KvEngine, T: RaftStoreRouter<EK>>(
raft_router: T,
mut detail: RegionDetailResponse,
) -> impl Future<Output = Result<()>> {
