Go client for TiKV
Go to file
Sandy Xu b0d9bb8821
Bump go version to 1.16 (#379)
* Revert "use ioutil.ReadFile to release dependency of Go 1.16 (#217)"

This reverts commit aadf3cf627.

Signed-off-by: Sandy Xu <sandy@juicedata.io>

* use go 1.16 for examples

Signed-off-by: Sandy Xu <sandy@juicedata.io>
2021-11-18 06:06:13 -08:00
.github Bump go version to 1.16 (#379) 2021-11-18 06:06:13 -08:00
config Bump go version to 1.16 (#379) 2021-11-18 06:06:13 -08:00
error errors: use As to check error type (#361) 2021-11-01 10:32:00 +00:00
examples Bump go version to 1.16 (#379) 2021-11-18 06:06:13 -08:00
integration_tests add newly inserted flag to optimize delete your write (#378) 2021-11-15 21:23:32 -08:00
internal Fix a typo (#376) 2021-11-15 15:10:40 +08:00
kv add newly inserted flag to optimize delete your write (#378) 2021-11-15 21:23:32 -08:00
metrics Add read throughput metric for SLI (#321) 2021-10-11 11:46:20 +08:00
oracle *: replace pingcap/errors with pkg/errors (#357) 2021-11-01 11:59:52 +08:00
rawkv *: replace pingcap/errors with pkg/errors (#357) 2021-11-01 11:59:52 +08:00
testutils fix license (#267) 2021-08-15 01:48:01 +08:00
tikv tikv: remove BeginWithOption method (#370) 2021-11-11 00:56:58 -08:00
tikvrpc txnkv: add callback for setting ResourceGroupTag (#368) 2021-11-14 19:11:14 -08:00
txnkv add newly inserted flag to optimize delete your write (#378) 2021-11-15 21:23:32 -08:00
util Print the Region key with a more readable format (#375) 2021-11-14 22:08:58 -08:00
.gitignore rechange to retry when tikv disk full (#302) 2021-09-15 13:01:35 +08:00
.golangci.yml ci: add golint (#212) 2021-07-05 11:02:07 +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 add juiceFS link (#248) 2021-07-22 18:38:31 +08:00
go.mod Bump go version to 1.16 (#379) 2021-11-18 06:06:13 -08:00
go.sum Update the PD client to the latest version (#352) 2021-10-29 10:40:11 +00: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 new active 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.

- warning: The v2 branch is still being refactored and sorted out, and external interfaces may change before the v2.0.0 release. Please use caution in production environments.

Usage/Examples

  go get github.com/tikv/client-go/v2@COMMIT_HASH_OR_TAG_VERSION

More examples can be found 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

License

Apache License 2.0