mirror of https://github.com/tikv/client-rust.git
Reverts changing `Box::pin`.
Signed-off-by: Steven Gu <asongala@163.com>
This commit is contained in:
parent
73b2e66430
commit
e3836ade98
22
src/mock.rs
22
src/mock.rs
|
@ -14,7 +14,7 @@ use crate::{
|
|||
};
|
||||
|
||||
use fail::fail_point;
|
||||
use futures::future::{BoxFuture, FutureExt};
|
||||
use futures::future::{ready, BoxFuture, FutureExt};
|
||||
use grpcio::CallOption;
|
||||
use kvproto::{errorpb, kvrpcpb, metapb};
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
@ -102,16 +102,13 @@ impl PdClient for MockPdClient {
|
|||
self: Arc<Self>,
|
||||
region: Region,
|
||||
) -> BoxFuture<'static, Result<Store<Self::KvClient>>> {
|
||||
let store = Store::new(
|
||||
Box::pin(ready(Ok(Store::new(
|
||||
region,
|
||||
MockKvClient {
|
||||
addr: String::new(),
|
||||
},
|
||||
Duration::from_secs(60),
|
||||
);
|
||||
|
||||
let future = async move { Ok(store) };
|
||||
future.boxed()
|
||||
))))
|
||||
}
|
||||
|
||||
fn region_for_key(&self, key: &Key) -> BoxFuture<'static, Result<Region>> {
|
||||
|
@ -122,8 +119,7 @@ impl PdClient for MockPdClient {
|
|||
Self::region2()
|
||||
};
|
||||
|
||||
let future = async move { Ok(region) };
|
||||
future.boxed()
|
||||
Box::pin(ready(Ok(region)))
|
||||
}
|
||||
|
||||
fn region_for_id(&self, id: RegionId) -> BoxFuture<'static, Result<Region>> {
|
||||
|
@ -133,8 +129,7 @@ impl PdClient for MockPdClient {
|
|||
_ => Err(Error::region_not_found(id)),
|
||||
};
|
||||
|
||||
let future = async move { result };
|
||||
future.boxed()
|
||||
Box::pin(ready(result))
|
||||
}
|
||||
|
||||
fn get_timestamp(self: Arc<Self>) -> BoxFuture<'static, Result<Timestamp>> {
|
||||
|
@ -150,11 +145,8 @@ impl DispatchHook for kvrpcpb::ResolveLockRequest {
|
|||
fail_point!("region-error", |_| {
|
||||
let mut resp = kvrpcpb::ResolveLockResponse::default();
|
||||
resp.region_error = Some(errorpb::Error::default());
|
||||
let future = async move { Ok(resp) };
|
||||
Some(future.boxed())
|
||||
Some(ready(Ok(resp)).boxed())
|
||||
});
|
||||
|
||||
let future = async { Ok(kvrpcpb::ResolveLockResponse::default()) };
|
||||
Some(future.boxed())
|
||||
Some(ready(Ok(kvrpcpb::ResolveLockResponse::default())).boxed())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue