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

Introduce API V2 #46

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/config/tikv.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[storage]
enable-ttl = true
api-version = 2
15 changes: 11 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
target/
key: cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
cargo-
cargo-
- name: Run format
env:
RUSTFLAGS: -Dwarnings
Expand Down Expand Up @@ -69,14 +69,21 @@ jobs:
working-directory: ./
run: |
cargo check
- name: Setup tikv instance
- name: Setup TiKV instance
run: |
curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh
/home/runner/.tiup/bin/tiup playground nightly --mode tikv-slim --without-monitor &
~/.tiup/bin/tiup install playground tikv:nightly pd:nightly
~/.tiup/bin/tiup playground nightly --mode tikv-slim \
--without-monitor --kv 3 --kv.config .github/config/tikv.toml &
while :; do
echo "waiting cluster to be ready"
[[ "$(curl -I http://127.0.0.1:2379/pd/api/v1/regions 2>/dev/null | head -n 1 | cut -d$' ' -f2)" -ne "405" ]] || break
sleep 1
done
- name: Setup tikv-service
run: |
cargo build -r
./target/release/tikv-service-server --config="config.toml" &
./target/release/tikv-service-server --config=config.toml &
- name: Setup test tool env
uses: actions/setup-python@v3
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/target
**/*.rs.bk
/.idea
**/__pycache__
**/*.log
17 changes: 12 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 17 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,36 @@ atoi = "0.3.2"
bytes = "1"
crc = "2.0"
structopt = "0.3.14"
slog = { version = "2.3", features = ["max_level_trace", "release_max_level_debug"] }
slog = { version = "2.3", features = [
"max_level_trace",
"release_max_level_debug",
] }
slog-term = { version = "2.4" }
tokio = { version = "1", features = ["full"] }
tokio-stream = "0.1"
tokio-util = { version = "0.7.1", features = ["rt"] }
tikv-client = { git = "https://github.com/yongman/client-rust.git", rev = "6675112143896419d233394b5e02612f50a72a3d" }
tikv-client = { git = "https://github.com/iosmanthus/client-rust.git", branch = "api-v2" }
lazy_static = "1.4.0"
thiserror = "1"
prometheus = { version = "0.13.0", features = ["process"]}
prometheus = { version = "0.13.0", features = ["process"] }
pprof = { version = "0.9", features = ["flamegraph", "protobuf-codec"] }
hyper = { version = "0.14.17", features = ["full"] }
async-std = { version = "1.11.0", features = ["unstable"] }
async-tls = { version = "0.11.0", features = ["server"], default-features = false }
async-tls = { version = "0.11.0", features = [
"server",
], default-features = false }
rustls = "0.19.0"
rand = {version = "0.8.5", features = ["small_rng"] }
rand = { version = "0.8.5", features = ["small_rng"] }
toml = { version = "0.5.8" }
serde = { version = "1.0", features = ["derive"] }
futures = { version = "0.3", default-features = false }
mlua = { version = "0.7.4", features = ["lua51", "async", "vendored", "macros", "send"]}
mlua = { version = "0.7.4", features = [
"lua51",
"async",
"vendored",
"macros",
"send",
] }
sha1 = "0.10.0"
hex = "0.4.3"

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.61.0
nightly-2022-05-01
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toolchain version changes needed?

Copy link
Member Author

@iosmanthus iosmanthus Jul 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This pull request depends on feature min_specification which is only enabled in nightly and cargo fmt --all complains some configs are only enabled in nightly. This nightly toolchain version is the same as TiKV.

2 changes: 1 addition & 1 deletion src/cmd/cmdtype.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::sync::Arc;

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use crate::tikv::errors::AsyncResult;
use crate::tikv::string::StringCommandCtx;
use crate::utils::resp_invalid_arguments;
use crate::{Connection, Frame, Parse};
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

use crate::config::is_use_txn_api;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/del.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ use std::sync::Arc;

use crate::config::is_use_txn_api;
use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use crate::tikv::errors::{AsyncResult, REDIS_NOT_SUPPORTED_ERR};
use crate::tikv::string::StringCommandCtx;
use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame, Parse};
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

use super::Invalid;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/exists.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use std::sync::Arc;

use crate::config::is_use_txn_api;
use crate::tikv::client::Transaction;
use crate::tikv::errors::AsyncResult;
use crate::tikv::string::StringCommandCtx;
use crate::utils::resp_invalid_arguments;
use crate::{Connection, Frame, Parse};
use tikv_client::Transaction;
use tokio::sync::Mutex;

use crate::cmd::Invalid;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/expire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ use std::sync::Arc;
use crate::cmd::Invalid;
use crate::config::is_use_txn_api;
use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use crate::tikv::errors::{AsyncResult, REDIS_NOT_SUPPORTED_ERR};
use crate::tikv::string::StringCommandCtx;
use crate::utils::{resp_err, resp_invalid_arguments, timestamp_from_ttl};
use crate::{Connection, Frame, Parse};
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/get.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::sync::Arc;

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use crate::tikv::errors::AsyncResult;
use crate::tikv::string::StringCommandCtx;
use crate::utils::resp_invalid_arguments;
use crate::{Connection, Frame, Parse};
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

use crate::config::is_use_txn_api;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hdel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hexists.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hgetall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hincrby.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hkeys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hlen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hmget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/hset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::{KvPair, Transaction};
use tikv_client::KvPair;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hstrlen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/hvals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/incrdecr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::{Connection, Frame, Parse};

use crate::cmd::Invalid;
use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/lindex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/linsert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use bytes::Bytes;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

use super::Invalid;
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/llen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/lrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

#[derive(Debug)]
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/lrem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ use crate::utils::{resp_err, resp_invalid_arguments};
use crate::{Connection, Frame};

use crate::config::LOGGER;
use crate::tikv::client::Transaction;
use bytes::Bytes;
use slog::debug;
use tikv_client::Transaction;
use tokio::sync::Mutex;

use super::Invalid;
Expand Down
Loading