Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove compat #149

Merged
merged 11 commits into from
Jul 26, 2020
Merged
43 changes: 27 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ os:
# - windows # TODO: https://github.com/pingcap/kvproto/issues/355
- osx
rust:
- stable
- nightly
- 1.42.0
- nightly-2020-01-07

env:
global:
Expand All @@ -27,28 +27,39 @@ addons:
- cmake
- go

before_install:
# travis will handle the toolchains' version
rm ./rust-toolchain

install:
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "stable" ]]; then rustup component add rustfmt; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "stable" ]]; then rustup component add clippy; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "1.42.0" ]]; then rustup component add rustfmt; fi
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then
wget https://dl.google.com/go/go1.14.1.linux-amd64.tar.gz;
tar -xf go1.14.1.linux-amd64.tar.gz -C $HOME;
export PATH="$HOME/go/bin:$PATH";
export GOROOT=$HOME/go;
fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "1.42.0" ]]; then rustup component add clippy; fi
- if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install golang cmake strawberryperl protoc; fi
- if [[ $TRAVIS_OS_NAME == "windows" ]]; then export PATH="$PATH:/c/Go/bin/:/c/Program Files/CMake/bin"; fi

before_script:
echo ""
- eval "$(gimme stable)"

script:
- which go && go version
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "stable" ]]; then cargo fmt -- --check; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "stable" ]]; then cargo clippy -- -D clippy::all; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "1.42.0" ]]; then cargo fmt -- --check; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "1.42.0" ]]; then cargo clippy -- -D clippy::all; fi
- cargo build --all
- cargo build --examples
- if [[ $TRAVIS_RUST_VERSION == "nightly" ]]; then cargo test --all -- --nocapture; fi
# For now we only run full integration tests on Linux. Here's why:
# * Docker on OS X is not supported by Travis.
# * Docker on Windows seems to not have the correct binary at `"/c/Program Files/Docker/Docker/DockerCli.exe" to switch it to Linux containers.
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly" ]]; then docker run -d --net=host --name pd --rm pingcap/pd:nightly --name "pd" --data-dir "pd" --client-urls "http://127.0.0.1:2379" --advertise-client-urls "http://127.0.0.1:2379"; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly" ]]; then docker run -d --net=host --name kv --rm --ulimit nofile=90000:90000 pingcap/tikv:nightly --pd-endpoints "127.0.0.1:2379" --addr "127.0.0.1:2378" --data-dir "kv"; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly" ]]; then docker ps; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly" ]]; then docker logs pd; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly" ]]; then docker logs kv; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly" ]]; then PD_ADDRS="127.0.0.1:2379" cargo test --all --features integration-tests -- --nocapture; fi
- if [[ $TRAVIS_RUST_VERSION == "nightly-2020-01-07" ]]; then cargo test --all -- --nocapture; fi
# For now we only run full integration tests on Linux. Here's why:
# * Docker on OS X is not supported by Travis.
# * Docker on Windows seems to not have the correct binary at `"/c/Program Files/Docker/Docker/DockerCli.exe" to switch it to Linux containers.
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly-2020-01-07" ]]; then docker run -d --net=host --name pd --rm pingcap/pd:nightly --name "pd" --data-dir "pd" --client-urls "http://127.0.0.1:2379" --advertise-client-urls "http://127.0.0.1:2379"; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly-2020-01-07" ]]; then docker run -d --net=host --name kv --rm --ulimit nofile=90000:90000 pingcap/tikv:nightly --pd-endpoints "127.0.0.1:2379" --addr "127.0.0.1:2378" --data-dir "kv"; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly-2020-01-07" ]]; then docker ps; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly-2020-01-07" ]]; then docker logs pd; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly-2020-01-07" ]]; then docker logs kv; fi
- if [[ $TRAVIS_OS_NAME == "linux" && $TRAVIS_RUST_VERSION == "nightly-2020-01-07" ]]; then PD_ADDRS="127.0.0.1:2379" cargo test --all --features integration-tests -- --nocapture; fi
7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ name = "tikv_client"
[dependencies]
derive-new = "0.5"
failure = "0.1"
futures = { version = "0.3.1", features = ["compat", "async-await", "thread-pool"] }
grpcio = { version = "0.5.0", features = [ "secure", "prost-codec" ], default-features = false }
kvproto = { git = "https://github.com/pingcap/kvproto.git", features = [ "prost-codec" ], default-features = false }
futures = { version = "0.3.1", features = ["async-await", "thread-pool"] }
grpcio = { git = "https://github.com/tikv/grpc-rs.git", features = [ "secure", "prost-codec" ], default-features = false }
kvproto = { git = "https://github.com/longfangsong/kvproto.git", features = [ "prost-codec" ], default-features = false }
lazy_static = "1"
log = "0.4"
rand = "0.7"
Expand All @@ -48,3 +48,4 @@ fail = { version = "0.3", features = [ "failpoints" ] }

[patch.crates-io]
raft-proto = { git = "https://github.com/tikv/raft-rs", rev = "e624c1d48460940a40d8aa69b5329460d9af87dd" }
grpcio-compiler = { git = "https://github.com/tikv/grpc-rs.git", version = "0.5.0", default-features = false }
1 change: 1 addition & 0 deletions rust-toolchain
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.42.0
5 changes: 2 additions & 3 deletions src/kv_client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use crate::{
};

use derive_new::new;
use futures::compat::Compat01As03;
use futures::future::BoxFuture;
use futures::prelude::*;
use grpcio::CallOption;
Expand Down Expand Up @@ -83,11 +82,11 @@ async fn map_errors_and_trace<Resp, RpcFuture>(
fut: ::grpcio::Result<RpcFuture>,
) -> Result<Resp>
where
Compat01As03<RpcFuture>: Future<Output = std::result::Result<Resp, ::grpcio::Error>>,
RpcFuture: Future<Output = std::result::Result<Resp, ::grpcio::Error>>,
Resp: HasError + Sized + Clone + Send + 'static,
{
let res = match fut {
Ok(f) => Compat01As03::new(f).await,
Ok(f) => f.await,
Err(e) => Err(e),
};

Expand Down
6 changes: 0 additions & 6 deletions src/pd/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use crate::{
transaction::Timestamp,
Error, Result,
};
use futures::compat::Compat01As03;
use futures::prelude::*;
use grpcio::{CallOption, Environment};
use kvproto::{metapb, pdpb};
Expand Down Expand Up @@ -56,7 +55,6 @@ impl Cluster {

self.client
.get_region_async_opt(&req, option)
.map(Compat01As03::new)
.unwrap()
.map(move |r| context.done(r.map_err(|e| e.into())))
.and_then(move |resp| {
Expand Down Expand Up @@ -87,7 +85,6 @@ impl Cluster {

self.client
.get_region_by_id_async_opt(&req, option)
.map(Compat01As03::new)
.unwrap()
.map(move |r| context.done(r.map_err(|e| e.into())))
.and_then(move |resp| {
Expand Down Expand Up @@ -116,7 +113,6 @@ impl Cluster {

self.client
.get_store_async_opt(&req, option)
.map(Compat01As03::new)
.unwrap()
.map(move |r| context.done(r.map_err(|e| e.into())))
.and_then(|mut resp| {
Expand All @@ -141,7 +137,6 @@ impl Cluster {

self.client
.get_all_stores_async_opt(&req, option)
.map(Compat01As03::new)
.unwrap()
.map(move |r| context.done(r.map_err(|e| e.into())))
.and_then(|mut resp| {
Expand Down Expand Up @@ -280,7 +275,6 @@ impl Connection {
let option = CallOption::default().timeout(timeout);
let resp = client
.get_members_async_opt(&pdpb::GetMembersRequest::default(), option)
.map(Compat01As03::new)
.map_err(Error::from)?
.await?;
Ok((client, resp))
Expand Down
5 changes: 2 additions & 3 deletions src/pd/timestamp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use crate::{transaction::Timestamp, Error, Result};

use futures::{
channel::{mpsc, oneshot},
compat::*,
executor::block_on,
join, pin_mut,
prelude::*,
Expand Down Expand Up @@ -54,8 +53,8 @@ impl TimestampOracle {
thread::spawn(move || {
block_on(run_tso(
cluster_id,
rpc_sender.sink_compat().sink_err_into(),
rpc_receiver.compat().err_into(),
rpc_sender.sink_err_into(),
rpc_receiver.err_into(),
request_rx,
))
});
Expand Down