Go client for TiKV
Go to file
glorv e80e9ca1fe
resource_control: add ru details in ExecDetails (#1070)
* collecting the RU information by pasing point through context.Value (#1032)

Signed-off-by: zzm <zhouzemin@pingcap.com>

* add ruWaitDuration to RUDetails and update pd-client

Signed-off-by: glorv <glorvs@163.com>

---------

Signed-off-by: zzm <zhouzemin@pingcap.com>
Signed-off-by: glorv <glorvs@163.com>
Co-authored-by: zzm <zhouzemin@pingcap.com>
2023-12-04 15:40:48 +08:00
.github ci: update go version (#936) 2023-08-10 22:05:00 +08:00
config config: enable user configuration for retry strategy. (#1055) 2023-11-14 14:54:10 +08:00
error reload region cache when store is resolved from invalid status (#843) 2023-07-14 13:27:14 +08:00
examples Bump google.golang.org/grpc in /examples/txnkv/pessimistic_txn (#1036) 2023-11-07 20:51:48 +08:00
integration_tests resource_control: add ru details in ExecDetails (#1070) 2023-12-04 15:40:48 +08:00
internal resource_control: add ru details in ExecDetails (#1070) 2023-12-04 15:40:48 +08:00
kv add more log for diagnose (#915) 2023-07-28 20:35:05 +08:00
metrics Revert "*: add metrics for batch client (#996)" (#1046) 2023-10-30 20:08:15 +08:00
oracle tso: merge lastTS and lastArrivalTS into an atomic pointer (#1054) 2023-11-15 16:34:14 +08:00
rawkv config: enable user configuration for retry strategy. (#1055) 2023-11-14 14:54:10 +08:00
testutils fix license (#267) 2021-08-15 01:48:01 +08:00
tikv resource_control: add ru details in ExecDetails (#1070) 2023-12-04 15:40:48 +08:00
tikvrpc Fix batch client batchSendLoop panic (#1021) 2023-10-17 15:44:06 +08:00
txnkv config: enable user configuration for retry strategy. (#1055) 2023-11-14 14:54:10 +08:00
util resource_control: add ru details in ExecDetails (#1070) 2023-12-04 15:40:48 +08:00
.gitignore rechange to retry when tikv disk full (#302) 2021-09-15 13:01:35 +08:00
.golangci.yml lock_resolver: handle pessimistic locks in BatchResolveLocks (#794) 2023-05-11 12:26:01 +08:00
CONTRIBUTING.md add contributing (#94) 2021-06-19 04:01:45 +08:00
LICENSE Initial commit 2018-12-01 12:03:35 +08:00
README.md Update README.md (#571) 2022-08-25 11:10:36 +08:00
go.mod resource_control: add ru details in ExecDetails (#1070) 2023-12-04 15:40:48 +08:00
go.sum resource_control: add ru details in ExecDetails (#1070) 2023-12-04 15:40:48 +08:00

README.md

TiKV Go Client

TiKV Go Client provides support for interacting with the TiKV server in the form of a Go library.

Stability Active Go Reference

Unit Test Integration Test Compatibility Test

Package versions

There are 2 major versions of the client-go package.

  • v2 is the latest stable version. This version was extracted from pingcap/tidb and it includes new TiKV features like Follower Read, 1PC, Async Commit. The development of this version is on the master branch. The documentation for this version is below.

  • v1 is the previous stable version and is only maintained for bug fixes. You can read the documentation here.

Usage/Examples

  # valid versions be like @latest, @e5f932ae270887550b0cd221343dbd6b870b6c8f, @v2.0.0, @v2.0.1...
  go get github.com/tikv/client-go/v2@COMMIT_HASH_OR_TAG_VERSION

Explanation of related concepts and sample code can be found in the Client-Go Wiki. There are also executable examples in examples directory.

Contributing to client-go

Pull Requests and issues are welcomed. Please check CONTRIBUTING.md.

Developing

Running Tests

Note: All the following tests are included in the CI and you can submit a Pull Request directly to hand over the work.

To run unit tests, use following command

go test ./...

To run code linter, make sure golangci-lint is installed. Then use following command

golangci-lint run

integration_tests can run against a real TiKV cluster. Here is an example:

./pd-server &
sleep 5
./tikv-server &
sleep 10
cd integration_tests
go test --with-tikv

Test with TiDB

It is a common task to update client-go and then test it with TiDB.

If you only need to test locally, you can directly use the modified client-go on the same host by replacing:

go mod edit -replace=github.com/tikv/client-go/v2=/path/to/client-go

If you want to push your TiDB code to GitHub for running CI or for code review, you need to change the client-go used by TiDB to your developing branch using the following steps:

go get -d github.com/GITHUB_USERNAME/client-go/v2@DEV_BRANCH
# Output:
# go get: github.com/GITHUB_USERNAME/client-go/v2@none updating to
#         github.com/GITHUB_USERNAME/client-go/v2@v2.0.0-XXXXXXXXXXXXXX-XXXXXXXXXXXX: parsing go.mod:
#         module declares its path as: github.com/tikv/client-go/v2
#                 but was required as: github.com/GITHUB_USERNAME/client-go/v2
go mod edit -replace=github.com/tikv/client-go/v2=github.com/GITHUB_USERNAME/client-go/v2@v2.0.0-XXXXXXXXXXXXXX-XXXXXXXXXXXX
go mod download github.com/tikv/client-go/v2

Used By

client-go is used by the following projects:

  • TiDB: TiDB is an open source distributed HTAP database compatible with the MySQL protocol
  • BR: A command-line tool for distributed backup and restoration of the TiDB cluster data
  • TiCDC: Change data capture for TiDB
  • go-ycsb: A Go port of Yahoo! Cloud Serving Benchmark (YCSB)
  • JuiceFS: JuiceFS is a distributed POSIX file system built on top of Redis and S3
  • tcli: A CLI tool for TiKV, for human being :)

License

Apache License 2.0