├── .github └── workflows │ └── run_app.yml ├── .gitignore ├── Cargo.lock ├── Cargo.toml ├── LICENSE ├── README.md ├── examples ├── error.js ├── raw_app.js ├── sync_raw_app.js ├── sync_transaction_app.js └── transaction_app.js ├── package-lock.json ├── package.json ├── rust-toolchain ├── src ├── error.rs ├── lib.rs ├── raw.rs ├── transaction.rs └── utils.rs ├── tikv_client ├── asynchronous │ └── index.ts ├── error.ts └── index.ts └── tsconfig.json /.github/workflows/run_app.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: CI 4 | 5 | # Controls when the workflow will run 6 | on: 7 | # Triggers the workflow on push or pull request events but only for the master branch 8 | push: 9 | branches: [ master ] 10 | pull_request: 11 | branches: [ master ] 12 | 13 | # Allows you to run this workflow manually from the Actions tab 14 | workflow_dispatch: 15 | 16 | # A workflow run is made up of one or more jobs that can run sequentially or in parallel 17 | jobs: 18 | # This workflow contains a single job called "build" 19 | build: 20 | # The type of runner that the job will run on 21 | runs-on: ubuntu-latest 22 | steps: 23 | - uses: actions/checkout@v2 24 | - uses: actions/setup-node@v2 25 | with: 26 | node-version: '14' 27 | - run: npm install 28 | - run: npm run build 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target 2 | index.node 3 | **/node_modules 4 | **/.DS_Store 5 | npm-debug.log* 6 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "adler" 7 | version = "1.0.2" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 10 | 11 | [[package]] 12 | name = "aho-corasick" 13 | version = "0.7.18" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" 16 | dependencies = [ 17 | "memchr", 18 | ] 19 | 20 | [[package]] 21 | name = "anyhow" 22 | version = "1.0.42" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486" 25 | 26 | [[package]] 27 | name = "async-recursion" 28 | version = "0.3.2" 29 | source = "registry+https://github.com/rust-lang/crates.io-index" 30 | checksum = "d7d78656ba01f1b93024b7c3a0467f1608e4be67d725749fdcd7d2c7678fd7a2" 31 | dependencies = [ 32 | "proc-macro2", 33 | "quote", 34 | "syn", 35 | ] 36 | 37 | [[package]] 38 | name = "async-trait" 39 | version = "0.1.50" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "0b98e84bbb4cbcdd97da190ba0c58a1bb0de2c1fdf67d159e192ed766aeca722" 42 | dependencies = [ 43 | "proc-macro2", 44 | "quote", 45 | "syn", 46 | ] 47 | 48 | [[package]] 49 | name = "atty" 50 | version = "0.2.14" 51 | source = "registry+https://github.com/rust-lang/crates.io-index" 52 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 53 | dependencies = [ 54 | "hermit-abi", 55 | "libc", 56 | "winapi", 57 | ] 58 | 59 | [[package]] 60 | name = "autocfg" 61 | version = "1.0.1" 62 | source = "registry+https://github.com/rust-lang/crates.io-index" 63 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 64 | 65 | [[package]] 66 | name = "base64" 67 | version = "0.13.0" 68 | source = "registry+https://github.com/rust-lang/crates.io-index" 69 | checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" 70 | 71 | [[package]] 72 | name = "bindgen" 73 | version = "0.57.0" 74 | source = "registry+https://github.com/rust-lang/crates.io-index" 75 | checksum = "fd4865004a46a0aafb2a0a5eb19d3c9fc46ee5f063a6cfc605c69ac9ecf5263d" 76 | dependencies = [ 77 | "bitflags", 78 | "cexpr", 79 | "clang-sys", 80 | "lazy_static", 81 | "lazycell", 82 | "peeking_take_while", 83 | "proc-macro2", 84 | "quote", 85 | "regex", 86 | "rustc-hash", 87 | "shlex", 88 | ] 89 | 90 | [[package]] 91 | name = "bitflags" 92 | version = "1.2.1" 93 | source = "registry+https://github.com/rust-lang/crates.io-index" 94 | checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" 95 | 96 | [[package]] 97 | name = "boringssl-src" 98 | version = "0.3.0+688fc5c" 99 | source = "registry+https://github.com/rust-lang/crates.io-index" 100 | checksum = "f901accdf830d2ea2f4e27f923a5e1125cd8b1a39ab578b9db1a42d578a6922b" 101 | dependencies = [ 102 | "cmake", 103 | ] 104 | 105 | [[package]] 106 | name = "bumpalo" 107 | version = "3.7.0" 108 | source = "registry+https://github.com/rust-lang/crates.io-index" 109 | checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" 110 | 111 | [[package]] 112 | name = "byteorder" 113 | version = "1.4.3" 114 | source = "registry+https://github.com/rust-lang/crates.io-index" 115 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 116 | 117 | [[package]] 118 | name = "bytes" 119 | version = "1.0.1" 120 | source = "registry+https://github.com/rust-lang/crates.io-index" 121 | checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" 122 | 123 | [[package]] 124 | name = "cc" 125 | version = "1.0.69" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" 128 | 129 | [[package]] 130 | name = "cexpr" 131 | version = "0.4.0" 132 | source = "registry+https://github.com/rust-lang/crates.io-index" 133 | checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" 134 | dependencies = [ 135 | "nom", 136 | ] 137 | 138 | [[package]] 139 | name = "cfg-if" 140 | version = "1.0.0" 141 | source = "registry+https://github.com/rust-lang/crates.io-index" 142 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 143 | 144 | [[package]] 145 | name = "chrono" 146 | version = "0.4.19" 147 | source = "registry+https://github.com/rust-lang/crates.io-index" 148 | checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" 149 | dependencies = [ 150 | "libc", 151 | "num-integer", 152 | "num-traits", 153 | "time", 154 | "winapi", 155 | ] 156 | 157 | [[package]] 158 | name = "clang-sys" 159 | version = "1.2.0" 160 | source = "registry+https://github.com/rust-lang/crates.io-index" 161 | checksum = "853eda514c284c2287f4bf20ae614f8781f40a81d32ecda6e91449304dfe077c" 162 | dependencies = [ 163 | "glob", 164 | "libc", 165 | "libloading 0.7.0", 166 | ] 167 | 168 | [[package]] 169 | name = "cmake" 170 | version = "0.1.45" 171 | source = "registry+https://github.com/rust-lang/crates.io-index" 172 | checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855" 173 | dependencies = [ 174 | "cc", 175 | ] 176 | 177 | [[package]] 178 | name = "core-foundation" 179 | version = "0.9.1" 180 | source = "registry+https://github.com/rust-lang/crates.io-index" 181 | checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" 182 | dependencies = [ 183 | "core-foundation-sys", 184 | "libc", 185 | ] 186 | 187 | [[package]] 188 | name = "core-foundation-sys" 189 | version = "0.8.2" 190 | source = "registry+https://github.com/rust-lang/crates.io-index" 191 | checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" 192 | 193 | [[package]] 194 | name = "crc32fast" 195 | version = "1.2.1" 196 | source = "registry+https://github.com/rust-lang/crates.io-index" 197 | checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" 198 | dependencies = [ 199 | "cfg-if", 200 | ] 201 | 202 | [[package]] 203 | name = "cslice" 204 | version = "0.2.0" 205 | source = "registry+https://github.com/rust-lang/crates.io-index" 206 | checksum = "697c714f50560202b1f4e2e09cd50a421881c83e9025db75d15f276616f04f40" 207 | 208 | [[package]] 209 | name = "derive-new" 210 | version = "0.5.9" 211 | source = "registry+https://github.com/rust-lang/crates.io-index" 212 | checksum = "3418329ca0ad70234b9735dc4ceed10af4df60eff9c8e7b06cb5e520d92c3535" 213 | dependencies = [ 214 | "proc-macro2", 215 | "quote", 216 | "syn", 217 | ] 218 | 219 | [[package]] 220 | name = "dirs-next" 221 | version = "2.0.0" 222 | source = "registry+https://github.com/rust-lang/crates.io-index" 223 | checksum = "b98cf8ebf19c3d1b223e151f99a4f9f0690dca41414773390fc824184ac833e1" 224 | dependencies = [ 225 | "cfg-if", 226 | "dirs-sys-next", 227 | ] 228 | 229 | [[package]] 230 | name = "dirs-sys-next" 231 | version = "0.1.2" 232 | source = "registry+https://github.com/rust-lang/crates.io-index" 233 | checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" 234 | dependencies = [ 235 | "libc", 236 | "redox_users", 237 | "winapi", 238 | ] 239 | 240 | [[package]] 241 | name = "either" 242 | version = "1.6.1" 243 | source = "registry+https://github.com/rust-lang/crates.io-index" 244 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 245 | 246 | [[package]] 247 | name = "encoding_rs" 248 | version = "0.8.28" 249 | source = "registry+https://github.com/rust-lang/crates.io-index" 250 | checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" 251 | dependencies = [ 252 | "cfg-if", 253 | ] 254 | 255 | [[package]] 256 | name = "fail" 257 | version = "0.4.0" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "3be3c61c59fdc91f5dbc3ea31ee8623122ce80057058be560654c5d410d181a6" 260 | dependencies = [ 261 | "lazy_static", 262 | "log", 263 | "rand 0.7.3", 264 | ] 265 | 266 | [[package]] 267 | name = "fixedbitset" 268 | version = "0.2.0" 269 | source = "registry+https://github.com/rust-lang/crates.io-index" 270 | checksum = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" 271 | 272 | [[package]] 273 | name = "flate2" 274 | version = "1.0.20" 275 | source = "registry+https://github.com/rust-lang/crates.io-index" 276 | checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" 277 | dependencies = [ 278 | "cfg-if", 279 | "crc32fast", 280 | "libc", 281 | "miniz_oxide", 282 | ] 283 | 284 | [[package]] 285 | name = "fnv" 286 | version = "1.0.7" 287 | source = "registry+https://github.com/rust-lang/crates.io-index" 288 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 289 | 290 | [[package]] 291 | name = "foreign-types" 292 | version = "0.3.2" 293 | source = "registry+https://github.com/rust-lang/crates.io-index" 294 | checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" 295 | dependencies = [ 296 | "foreign-types-shared", 297 | ] 298 | 299 | [[package]] 300 | name = "foreign-types-shared" 301 | version = "0.1.1" 302 | source = "registry+https://github.com/rust-lang/crates.io-index" 303 | checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" 304 | 305 | [[package]] 306 | name = "form_urlencoded" 307 | version = "1.0.1" 308 | source = "registry+https://github.com/rust-lang/crates.io-index" 309 | checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" 310 | dependencies = [ 311 | "matches", 312 | "percent-encoding", 313 | ] 314 | 315 | [[package]] 316 | name = "futures" 317 | version = "0.1.31" 318 | source = "registry+https://github.com/rust-lang/crates.io-index" 319 | checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" 320 | 321 | [[package]] 322 | name = "futures" 323 | version = "0.3.15" 324 | source = "registry+https://github.com/rust-lang/crates.io-index" 325 | checksum = "0e7e43a803dae2fa37c1f6a8fe121e1f7bf9548b4dfc0522a42f34145dadfc27" 326 | dependencies = [ 327 | "futures-channel", 328 | "futures-core", 329 | "futures-executor", 330 | "futures-io", 331 | "futures-sink", 332 | "futures-task", 333 | "futures-util", 334 | ] 335 | 336 | [[package]] 337 | name = "futures-channel" 338 | version = "0.3.15" 339 | source = "registry+https://github.com/rust-lang/crates.io-index" 340 | checksum = "e682a68b29a882df0545c143dc3646daefe80ba479bcdede94d5a703de2871e2" 341 | dependencies = [ 342 | "futures-core", 343 | "futures-sink", 344 | ] 345 | 346 | [[package]] 347 | name = "futures-core" 348 | version = "0.3.15" 349 | source = "registry+https://github.com/rust-lang/crates.io-index" 350 | checksum = "0402f765d8a89a26043b889b26ce3c4679d268fa6bb22cd7c6aad98340e179d1" 351 | 352 | [[package]] 353 | name = "futures-executor" 354 | version = "0.3.15" 355 | source = "registry+https://github.com/rust-lang/crates.io-index" 356 | checksum = "badaa6a909fac9e7236d0620a2f57f7664640c56575b71a7552fbd68deafab79" 357 | dependencies = [ 358 | "futures-core", 359 | "futures-task", 360 | "futures-util", 361 | "num_cpus", 362 | ] 363 | 364 | [[package]] 365 | name = "futures-io" 366 | version = "0.3.15" 367 | source = "registry+https://github.com/rust-lang/crates.io-index" 368 | checksum = "acc499defb3b348f8d8f3f66415835a9131856ff7714bf10dadfc4ec4bdb29a1" 369 | 370 | [[package]] 371 | name = "futures-macro" 372 | version = "0.3.15" 373 | source = "registry+https://github.com/rust-lang/crates.io-index" 374 | checksum = "a4c40298486cdf52cc00cd6d6987892ba502c7656a16a4192a9992b1ccedd121" 375 | dependencies = [ 376 | "autocfg", 377 | "proc-macro-hack", 378 | "proc-macro2", 379 | "quote", 380 | "syn", 381 | ] 382 | 383 | [[package]] 384 | name = "futures-sink" 385 | version = "0.3.15" 386 | source = "registry+https://github.com/rust-lang/crates.io-index" 387 | checksum = "a57bead0ceff0d6dde8f465ecd96c9338121bb7717d3e7b108059531870c4282" 388 | 389 | [[package]] 390 | name = "futures-task" 391 | version = "0.3.15" 392 | source = "registry+https://github.com/rust-lang/crates.io-index" 393 | checksum = "8a16bef9fc1a4dddb5bee51c989e3fbba26569cbb0e31f5b303c184e3dd33dae" 394 | 395 | [[package]] 396 | name = "futures-timer" 397 | version = "3.0.2" 398 | source = "registry+https://github.com/rust-lang/crates.io-index" 399 | checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c" 400 | 401 | [[package]] 402 | name = "futures-util" 403 | version = "0.3.15" 404 | source = "registry+https://github.com/rust-lang/crates.io-index" 405 | checksum = "feb5c238d27e2bf94ffdfd27b2c29e3df4a68c4193bb6427384259e2bf191967" 406 | dependencies = [ 407 | "autocfg", 408 | "futures 0.1.31", 409 | "futures-channel", 410 | "futures-core", 411 | "futures-io", 412 | "futures-macro", 413 | "futures-sink", 414 | "futures-task", 415 | "memchr", 416 | "pin-project-lite", 417 | "pin-utils", 418 | "proc-macro-hack", 419 | "proc-macro-nested", 420 | "slab", 421 | ] 422 | 423 | [[package]] 424 | name = "getrandom" 425 | version = "0.1.16" 426 | source = "registry+https://github.com/rust-lang/crates.io-index" 427 | checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" 428 | dependencies = [ 429 | "cfg-if", 430 | "libc", 431 | "wasi 0.9.0+wasi-snapshot-preview1", 432 | ] 433 | 434 | [[package]] 435 | name = "getrandom" 436 | version = "0.2.3" 437 | source = "registry+https://github.com/rust-lang/crates.io-index" 438 | checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" 439 | dependencies = [ 440 | "cfg-if", 441 | "libc", 442 | "wasi 0.10.2+wasi-snapshot-preview1", 443 | ] 444 | 445 | [[package]] 446 | name = "glob" 447 | version = "0.3.0" 448 | source = "registry+https://github.com/rust-lang/crates.io-index" 449 | checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" 450 | 451 | [[package]] 452 | name = "grpcio" 453 | version = "0.9.0" 454 | source = "registry+https://github.com/rust-lang/crates.io-index" 455 | checksum = "2a1b8dd4e79b81ccfd5b9282dfc6d3d4e97568291c383c1bc98756a0f21e39d9" 456 | dependencies = [ 457 | "bytes", 458 | "futures 0.3.15", 459 | "grpcio-sys", 460 | "libc", 461 | "log", 462 | "parking_lot", 463 | "prost", 464 | ] 465 | 466 | [[package]] 467 | name = "grpcio-compiler" 468 | version = "0.9.0" 469 | source = "registry+https://github.com/rust-lang/crates.io-index" 470 | checksum = "4caa0700833147dcfbe4f0758bd92545cc0f4506ee7fa154e499745a8b24e86c" 471 | dependencies = [ 472 | "derive-new", 473 | "prost", 474 | "prost-build", 475 | "prost-types", 476 | "tempfile", 477 | ] 478 | 479 | [[package]] 480 | name = "grpcio-sys" 481 | version = "0.9.0+1.38.0" 482 | source = "registry+https://github.com/rust-lang/crates.io-index" 483 | checksum = "0cdbbb3010823156c3153b75db391c0f47beeec57353a33dfa38126b265cc1d5" 484 | dependencies = [ 485 | "bindgen", 486 | "boringssl-src", 487 | "cc", 488 | "cmake", 489 | "libc", 490 | "libz-sys", 491 | "openssl-sys", 492 | "pkg-config", 493 | "walkdir", 494 | ] 495 | 496 | [[package]] 497 | name = "h2" 498 | version = "0.3.3" 499 | source = "registry+https://github.com/rust-lang/crates.io-index" 500 | checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" 501 | dependencies = [ 502 | "bytes", 503 | "fnv", 504 | "futures-core", 505 | "futures-sink", 506 | "futures-util", 507 | "http", 508 | "indexmap", 509 | "slab", 510 | "tokio", 511 | "tokio-util", 512 | "tracing", 513 | ] 514 | 515 | [[package]] 516 | name = "hashbrown" 517 | version = "0.11.2" 518 | source = "registry+https://github.com/rust-lang/crates.io-index" 519 | checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 520 | 521 | [[package]] 522 | name = "heck" 523 | version = "0.3.3" 524 | source = "registry+https://github.com/rust-lang/crates.io-index" 525 | checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" 526 | dependencies = [ 527 | "unicode-segmentation", 528 | ] 529 | 530 | [[package]] 531 | name = "hermit-abi" 532 | version = "0.1.19" 533 | source = "registry+https://github.com/rust-lang/crates.io-index" 534 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 535 | dependencies = [ 536 | "libc", 537 | ] 538 | 539 | [[package]] 540 | name = "hex" 541 | version = "0.4.3" 542 | source = "registry+https://github.com/rust-lang/crates.io-index" 543 | checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" 544 | 545 | [[package]] 546 | name = "http" 547 | version = "0.2.4" 548 | source = "registry+https://github.com/rust-lang/crates.io-index" 549 | checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" 550 | dependencies = [ 551 | "bytes", 552 | "fnv", 553 | "itoa", 554 | ] 555 | 556 | [[package]] 557 | name = "http-body" 558 | version = "0.4.2" 559 | source = "registry+https://github.com/rust-lang/crates.io-index" 560 | checksum = "60daa14be0e0786db0f03a9e57cb404c9d756eed2b6c62b9ea98ec5743ec75a9" 561 | dependencies = [ 562 | "bytes", 563 | "http", 564 | "pin-project-lite", 565 | ] 566 | 567 | [[package]] 568 | name = "httparse" 569 | version = "1.4.1" 570 | source = "registry+https://github.com/rust-lang/crates.io-index" 571 | checksum = "f3a87b616e37e93c22fb19bcd386f02f3af5ea98a25670ad0fce773de23c5e68" 572 | 573 | [[package]] 574 | name = "httpdate" 575 | version = "1.0.1" 576 | source = "registry+https://github.com/rust-lang/crates.io-index" 577 | checksum = "6456b8a6c8f33fee7d958fcd1b60d55b11940a79e63ae87013e6d22e26034440" 578 | 579 | [[package]] 580 | name = "hyper" 581 | version = "0.14.11" 582 | source = "registry+https://github.com/rust-lang/crates.io-index" 583 | checksum = "0b61cf2d1aebcf6e6352c97b81dc2244ca29194be1b276f5d8ad5c6330fffb11" 584 | dependencies = [ 585 | "bytes", 586 | "futures-channel", 587 | "futures-core", 588 | "futures-util", 589 | "h2", 590 | "http", 591 | "http-body", 592 | "httparse", 593 | "httpdate", 594 | "itoa", 595 | "pin-project-lite", 596 | "socket2", 597 | "tokio", 598 | "tower-service", 599 | "tracing", 600 | "want", 601 | ] 602 | 603 | [[package]] 604 | name = "hyper-tls" 605 | version = "0.5.0" 606 | source = "registry+https://github.com/rust-lang/crates.io-index" 607 | checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" 608 | dependencies = [ 609 | "bytes", 610 | "hyper", 611 | "native-tls", 612 | "tokio", 613 | "tokio-native-tls", 614 | ] 615 | 616 | [[package]] 617 | name = "idna" 618 | version = "0.2.3" 619 | source = "registry+https://github.com/rust-lang/crates.io-index" 620 | checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" 621 | dependencies = [ 622 | "matches", 623 | "unicode-bidi", 624 | "unicode-normalization", 625 | ] 626 | 627 | [[package]] 628 | name = "indexmap" 629 | version = "1.7.0" 630 | source = "registry+https://github.com/rust-lang/crates.io-index" 631 | checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" 632 | dependencies = [ 633 | "autocfg", 634 | "hashbrown", 635 | ] 636 | 637 | [[package]] 638 | name = "instant" 639 | version = "0.1.10" 640 | source = "registry+https://github.com/rust-lang/crates.io-index" 641 | checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" 642 | dependencies = [ 643 | "cfg-if", 644 | ] 645 | 646 | [[package]] 647 | name = "ipnet" 648 | version = "2.3.1" 649 | source = "registry+https://github.com/rust-lang/crates.io-index" 650 | checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" 651 | 652 | [[package]] 653 | name = "itertools" 654 | version = "0.9.0" 655 | source = "registry+https://github.com/rust-lang/crates.io-index" 656 | checksum = "284f18f85651fe11e8a991b2adb42cb078325c996ed026d994719efcfca1d54b" 657 | dependencies = [ 658 | "either", 659 | ] 660 | 661 | [[package]] 662 | name = "itoa" 663 | version = "0.4.7" 664 | source = "registry+https://github.com/rust-lang/crates.io-index" 665 | checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" 666 | 667 | [[package]] 668 | name = "js-sys" 669 | version = "0.3.51" 670 | source = "registry+https://github.com/rust-lang/crates.io-index" 671 | checksum = "83bdfbace3a0e81a4253f73b49e960b053e396a11012cbd49b9b74d6a2b67062" 672 | dependencies = [ 673 | "wasm-bindgen", 674 | ] 675 | 676 | [[package]] 677 | name = "lazy_static" 678 | version = "1.4.0" 679 | source = "registry+https://github.com/rust-lang/crates.io-index" 680 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 681 | 682 | [[package]] 683 | name = "lazycell" 684 | version = "1.3.0" 685 | source = "registry+https://github.com/rust-lang/crates.io-index" 686 | checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" 687 | 688 | [[package]] 689 | name = "libc" 690 | version = "0.2.98" 691 | source = "registry+https://github.com/rust-lang/crates.io-index" 692 | checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" 693 | 694 | [[package]] 695 | name = "libloading" 696 | version = "0.6.7" 697 | source = "registry+https://github.com/rust-lang/crates.io-index" 698 | checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" 699 | dependencies = [ 700 | "cfg-if", 701 | "winapi", 702 | ] 703 | 704 | [[package]] 705 | name = "libloading" 706 | version = "0.7.0" 707 | source = "registry+https://github.com/rust-lang/crates.io-index" 708 | checksum = "6f84d96438c15fcd6c3f244c8fce01d1e2b9c6b5623e9c711dc9286d8fc92d6a" 709 | dependencies = [ 710 | "cfg-if", 711 | "winapi", 712 | ] 713 | 714 | [[package]] 715 | name = "libz-sys" 716 | version = "1.1.3" 717 | source = "registry+https://github.com/rust-lang/crates.io-index" 718 | checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" 719 | dependencies = [ 720 | "cc", 721 | "libc", 722 | "pkg-config", 723 | "vcpkg", 724 | ] 725 | 726 | [[package]] 727 | name = "lock_api" 728 | version = "0.4.4" 729 | source = "registry+https://github.com/rust-lang/crates.io-index" 730 | checksum = "0382880606dff6d15c9476c416d18690b72742aa7b605bb6dd6ec9030fbf07eb" 731 | dependencies = [ 732 | "scopeguard", 733 | ] 734 | 735 | [[package]] 736 | name = "log" 737 | version = "0.4.14" 738 | source = "registry+https://github.com/rust-lang/crates.io-index" 739 | checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 740 | dependencies = [ 741 | "cfg-if", 742 | ] 743 | 744 | [[package]] 745 | name = "matches" 746 | version = "0.1.8" 747 | source = "registry+https://github.com/rust-lang/crates.io-index" 748 | checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" 749 | 750 | [[package]] 751 | name = "memchr" 752 | version = "2.4.0" 753 | source = "registry+https://github.com/rust-lang/crates.io-index" 754 | checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" 755 | 756 | [[package]] 757 | name = "mime" 758 | version = "0.3.16" 759 | source = "registry+https://github.com/rust-lang/crates.io-index" 760 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" 761 | 762 | [[package]] 763 | name = "miniz_oxide" 764 | version = "0.4.4" 765 | source = "registry+https://github.com/rust-lang/crates.io-index" 766 | checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" 767 | dependencies = [ 768 | "adler", 769 | "autocfg", 770 | ] 771 | 772 | [[package]] 773 | name = "mio" 774 | version = "0.7.13" 775 | source = "registry+https://github.com/rust-lang/crates.io-index" 776 | checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" 777 | dependencies = [ 778 | "libc", 779 | "log", 780 | "miow", 781 | "ntapi", 782 | "winapi", 783 | ] 784 | 785 | [[package]] 786 | name = "miow" 787 | version = "0.3.7" 788 | source = "registry+https://github.com/rust-lang/crates.io-index" 789 | checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" 790 | dependencies = [ 791 | "winapi", 792 | ] 793 | 794 | [[package]] 795 | name = "multimap" 796 | version = "0.8.3" 797 | source = "registry+https://github.com/rust-lang/crates.io-index" 798 | checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" 799 | 800 | [[package]] 801 | name = "native-tls" 802 | version = "0.2.7" 803 | source = "registry+https://github.com/rust-lang/crates.io-index" 804 | checksum = "b8d96b2e1c8da3957d58100b09f102c6d9cfdfced01b7ec5a8974044bb09dbd4" 805 | dependencies = [ 806 | "lazy_static", 807 | "libc", 808 | "log", 809 | "openssl", 810 | "openssl-probe", 811 | "openssl-sys", 812 | "schannel", 813 | "security-framework", 814 | "security-framework-sys", 815 | "tempfile", 816 | ] 817 | 818 | [[package]] 819 | name = "neon" 820 | version = "0.8.3" 821 | source = "registry+https://github.com/rust-lang/crates.io-index" 822 | checksum = "05c562b89fa7f9707f02056abe25a37ec290ca4a4f1596edbd7aa1aa7b87af1d" 823 | dependencies = [ 824 | "cslice", 825 | "neon-build", 826 | "neon-macros", 827 | "neon-runtime", 828 | "semver", 829 | "smallvec", 830 | ] 831 | 832 | [[package]] 833 | name = "neon-build" 834 | version = "0.8.3" 835 | source = "registry+https://github.com/rust-lang/crates.io-index" 836 | checksum = "f9c55f6d310757b9fe6cd96a376609548a252da31828f935a7f59106533a89e9" 837 | 838 | [[package]] 839 | name = "neon-macros" 840 | version = "0.8.3" 841 | source = "registry+https://github.com/rust-lang/crates.io-index" 842 | checksum = "47065bc93b16f41fcfe29cad7d4d2a3e299b4389a3c9b429ba7a55f69a057fff" 843 | dependencies = [ 844 | "quote", 845 | "syn", 846 | ] 847 | 848 | [[package]] 849 | name = "neon-runtime" 850 | version = "0.8.3" 851 | source = "registry+https://github.com/rust-lang/crates.io-index" 852 | checksum = "be313e6cf11f469653ee1b137b9203f5d604f2b496d423e96c5e251b51eead03" 853 | dependencies = [ 854 | "cfg-if", 855 | "libloading 0.6.7", 856 | "smallvec", 857 | ] 858 | 859 | [[package]] 860 | name = "nom" 861 | version = "5.1.2" 862 | source = "registry+https://github.com/rust-lang/crates.io-index" 863 | checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" 864 | dependencies = [ 865 | "memchr", 866 | "version_check", 867 | ] 868 | 869 | [[package]] 870 | name = "ntapi" 871 | version = "0.3.6" 872 | source = "registry+https://github.com/rust-lang/crates.io-index" 873 | checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" 874 | dependencies = [ 875 | "winapi", 876 | ] 877 | 878 | [[package]] 879 | name = "num-integer" 880 | version = "0.1.44" 881 | source = "registry+https://github.com/rust-lang/crates.io-index" 882 | checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" 883 | dependencies = [ 884 | "autocfg", 885 | "num-traits", 886 | ] 887 | 888 | [[package]] 889 | name = "num-traits" 890 | version = "0.2.14" 891 | source = "registry+https://github.com/rust-lang/crates.io-index" 892 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" 893 | dependencies = [ 894 | "autocfg", 895 | ] 896 | 897 | [[package]] 898 | name = "num_cpus" 899 | version = "1.13.0" 900 | source = "registry+https://github.com/rust-lang/crates.io-index" 901 | checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" 902 | dependencies = [ 903 | "hermit-abi", 904 | "libc", 905 | ] 906 | 907 | [[package]] 908 | name = "once_cell" 909 | version = "1.8.0" 910 | source = "registry+https://github.com/rust-lang/crates.io-index" 911 | checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" 912 | 913 | [[package]] 914 | name = "openssl" 915 | version = "0.10.35" 916 | source = "registry+https://github.com/rust-lang/crates.io-index" 917 | checksum = "549430950c79ae24e6d02e0b7404534ecf311d94cc9f861e9e4020187d13d885" 918 | dependencies = [ 919 | "bitflags", 920 | "cfg-if", 921 | "foreign-types", 922 | "libc", 923 | "once_cell", 924 | "openssl-sys", 925 | ] 926 | 927 | [[package]] 928 | name = "openssl-probe" 929 | version = "0.1.4" 930 | source = "registry+https://github.com/rust-lang/crates.io-index" 931 | checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" 932 | 933 | [[package]] 934 | name = "openssl-src" 935 | version = "111.15.0+1.1.1k" 936 | source = "registry+https://github.com/rust-lang/crates.io-index" 937 | checksum = "b1a5f6ae2ac04393b217ea9f700cd04fa9bf3d93fae2872069f3d15d908af70a" 938 | dependencies = [ 939 | "cc", 940 | ] 941 | 942 | [[package]] 943 | name = "openssl-sys" 944 | version = "0.9.65" 945 | source = "registry+https://github.com/rust-lang/crates.io-index" 946 | checksum = "7a7907e3bfa08bb85105209cdfcb6c63d109f8f6c1ed6ca318fff5c1853fbc1d" 947 | dependencies = [ 948 | "autocfg", 949 | "cc", 950 | "libc", 951 | "openssl-src", 952 | "pkg-config", 953 | "vcpkg", 954 | ] 955 | 956 | [[package]] 957 | name = "parking_lot" 958 | version = "0.11.1" 959 | source = "registry+https://github.com/rust-lang/crates.io-index" 960 | checksum = "6d7744ac029df22dca6284efe4e898991d28e3085c706c972bcd7da4a27a15eb" 961 | dependencies = [ 962 | "instant", 963 | "lock_api", 964 | "parking_lot_core", 965 | ] 966 | 967 | [[package]] 968 | name = "parking_lot_core" 969 | version = "0.8.3" 970 | source = "registry+https://github.com/rust-lang/crates.io-index" 971 | checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" 972 | dependencies = [ 973 | "cfg-if", 974 | "instant", 975 | "libc", 976 | "redox_syscall", 977 | "smallvec", 978 | "winapi", 979 | ] 980 | 981 | [[package]] 982 | name = "peeking_take_while" 983 | version = "0.1.2" 984 | source = "registry+https://github.com/rust-lang/crates.io-index" 985 | checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" 986 | 987 | [[package]] 988 | name = "percent-encoding" 989 | version = "2.1.0" 990 | source = "registry+https://github.com/rust-lang/crates.io-index" 991 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 992 | 993 | [[package]] 994 | name = "petgraph" 995 | version = "0.5.1" 996 | source = "registry+https://github.com/rust-lang/crates.io-index" 997 | checksum = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" 998 | dependencies = [ 999 | "fixedbitset", 1000 | "indexmap", 1001 | ] 1002 | 1003 | [[package]] 1004 | name = "pin-project-lite" 1005 | version = "0.2.7" 1006 | source = "registry+https://github.com/rust-lang/crates.io-index" 1007 | checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" 1008 | 1009 | [[package]] 1010 | name = "pin-utils" 1011 | version = "0.1.0" 1012 | source = "registry+https://github.com/rust-lang/crates.io-index" 1013 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 1014 | 1015 | [[package]] 1016 | name = "pkg-config" 1017 | version = "0.3.19" 1018 | source = "registry+https://github.com/rust-lang/crates.io-index" 1019 | checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" 1020 | 1021 | [[package]] 1022 | name = "ppv-lite86" 1023 | version = "0.2.10" 1024 | source = "registry+https://github.com/rust-lang/crates.io-index" 1025 | checksum = "ac74c624d6b2d21f425f752262f42188365d7b8ff1aff74c82e45136510a4857" 1026 | 1027 | [[package]] 1028 | name = "proc-macro-hack" 1029 | version = "0.5.19" 1030 | source = "registry+https://github.com/rust-lang/crates.io-index" 1031 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" 1032 | 1033 | [[package]] 1034 | name = "proc-macro-nested" 1035 | version = "0.1.7" 1036 | source = "registry+https://github.com/rust-lang/crates.io-index" 1037 | checksum = "bc881b2c22681370c6a780e47af9840ef841837bc98118431d4e1868bd0c1086" 1038 | 1039 | [[package]] 1040 | name = "proc-macro2" 1041 | version = "1.0.28" 1042 | source = "registry+https://github.com/rust-lang/crates.io-index" 1043 | checksum = "5c7ed8b8c7b886ea3ed7dde405212185f423ab44682667c8c6dd14aa1d9f6612" 1044 | dependencies = [ 1045 | "unicode-xid", 1046 | ] 1047 | 1048 | [[package]] 1049 | name = "procfs" 1050 | version = "0.9.1" 1051 | source = "registry+https://github.com/rust-lang/crates.io-index" 1052 | checksum = "ab8809e0c18450a2db0f236d2a44ec0b4c1412d0eb936233579f0990faa5d5cd" 1053 | dependencies = [ 1054 | "bitflags", 1055 | "byteorder", 1056 | "flate2", 1057 | "hex", 1058 | "lazy_static", 1059 | "libc", 1060 | ] 1061 | 1062 | [[package]] 1063 | name = "prometheus" 1064 | version = "0.12.0" 1065 | source = "registry+https://github.com/rust-lang/crates.io-index" 1066 | checksum = "5986aa8d62380092d2f50f8b1cdba9cb9b6731ffd4b25b51fd126b6c3e05b99c" 1067 | dependencies = [ 1068 | "cfg-if", 1069 | "fnv", 1070 | "lazy_static", 1071 | "libc", 1072 | "memchr", 1073 | "parking_lot", 1074 | "procfs", 1075 | "protobuf", 1076 | "reqwest", 1077 | "thiserror", 1078 | ] 1079 | 1080 | [[package]] 1081 | name = "prost" 1082 | version = "0.7.0" 1083 | source = "registry+https://github.com/rust-lang/crates.io-index" 1084 | checksum = "9e6984d2f1a23009bd270b8bb56d0926810a3d483f59c987d77969e9d8e840b2" 1085 | dependencies = [ 1086 | "bytes", 1087 | "prost-derive", 1088 | ] 1089 | 1090 | [[package]] 1091 | name = "prost-build" 1092 | version = "0.7.0" 1093 | source = "registry+https://github.com/rust-lang/crates.io-index" 1094 | checksum = "32d3ebd75ac2679c2af3a92246639f9fcc8a442ee420719cc4fe195b98dd5fa3" 1095 | dependencies = [ 1096 | "bytes", 1097 | "heck", 1098 | "itertools", 1099 | "log", 1100 | "multimap", 1101 | "petgraph", 1102 | "prost", 1103 | "prost-types", 1104 | "tempfile", 1105 | "which", 1106 | ] 1107 | 1108 | [[package]] 1109 | name = "prost-derive" 1110 | version = "0.7.0" 1111 | source = "registry+https://github.com/rust-lang/crates.io-index" 1112 | checksum = "169a15f3008ecb5160cba7d37bcd690a7601b6d30cfb87a117d45e59d52af5d4" 1113 | dependencies = [ 1114 | "anyhow", 1115 | "itertools", 1116 | "proc-macro2", 1117 | "quote", 1118 | "syn", 1119 | ] 1120 | 1121 | [[package]] 1122 | name = "prost-types" 1123 | version = "0.7.0" 1124 | source = "registry+https://github.com/rust-lang/crates.io-index" 1125 | checksum = "b518d7cdd93dab1d1122cf07fa9a60771836c668dde9d9e2a139f957f0d9f1bb" 1126 | dependencies = [ 1127 | "bytes", 1128 | "prost", 1129 | ] 1130 | 1131 | [[package]] 1132 | name = "protobuf" 1133 | version = "2.24.1" 1134 | source = "registry+https://github.com/rust-lang/crates.io-index" 1135 | checksum = "db50e77ae196458ccd3dc58a31ea1a90b0698ab1b7928d89f644c25d72070267" 1136 | 1137 | [[package]] 1138 | name = "protobuf-build" 1139 | version = "0.12.3" 1140 | source = "registry+https://github.com/rust-lang/crates.io-index" 1141 | checksum = "6a7266835d38c38c73b091a24412de1f4b4382a5195fab1ec038161582b03b78" 1142 | dependencies = [ 1143 | "bitflags", 1144 | "grpcio-compiler", 1145 | "proc-macro2", 1146 | "prost-build", 1147 | "quote", 1148 | "syn", 1149 | ] 1150 | 1151 | [[package]] 1152 | name = "quote" 1153 | version = "1.0.9" 1154 | source = "registry+https://github.com/rust-lang/crates.io-index" 1155 | checksum = "c3d0b9745dc2debf507c8422de05d7226cc1f0644216dfdfead988f9b1ab32a7" 1156 | dependencies = [ 1157 | "proc-macro2", 1158 | ] 1159 | 1160 | [[package]] 1161 | name = "rand" 1162 | version = "0.7.3" 1163 | source = "registry+https://github.com/rust-lang/crates.io-index" 1164 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" 1165 | dependencies = [ 1166 | "getrandom 0.1.16", 1167 | "libc", 1168 | "rand_chacha 0.2.2", 1169 | "rand_core 0.5.1", 1170 | "rand_hc 0.2.0", 1171 | ] 1172 | 1173 | [[package]] 1174 | name = "rand" 1175 | version = "0.8.4" 1176 | source = "registry+https://github.com/rust-lang/crates.io-index" 1177 | checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" 1178 | dependencies = [ 1179 | "libc", 1180 | "rand_chacha 0.3.1", 1181 | "rand_core 0.6.3", 1182 | "rand_hc 0.3.1", 1183 | ] 1184 | 1185 | [[package]] 1186 | name = "rand_chacha" 1187 | version = "0.2.2" 1188 | source = "registry+https://github.com/rust-lang/crates.io-index" 1189 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" 1190 | dependencies = [ 1191 | "ppv-lite86", 1192 | "rand_core 0.5.1", 1193 | ] 1194 | 1195 | [[package]] 1196 | name = "rand_chacha" 1197 | version = "0.3.1" 1198 | source = "registry+https://github.com/rust-lang/crates.io-index" 1199 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 1200 | dependencies = [ 1201 | "ppv-lite86", 1202 | "rand_core 0.6.3", 1203 | ] 1204 | 1205 | [[package]] 1206 | name = "rand_core" 1207 | version = "0.5.1" 1208 | source = "registry+https://github.com/rust-lang/crates.io-index" 1209 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" 1210 | dependencies = [ 1211 | "getrandom 0.1.16", 1212 | ] 1213 | 1214 | [[package]] 1215 | name = "rand_core" 1216 | version = "0.6.3" 1217 | source = "registry+https://github.com/rust-lang/crates.io-index" 1218 | checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" 1219 | dependencies = [ 1220 | "getrandom 0.2.3", 1221 | ] 1222 | 1223 | [[package]] 1224 | name = "rand_hc" 1225 | version = "0.2.0" 1226 | source = "registry+https://github.com/rust-lang/crates.io-index" 1227 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" 1228 | dependencies = [ 1229 | "rand_core 0.5.1", 1230 | ] 1231 | 1232 | [[package]] 1233 | name = "rand_hc" 1234 | version = "0.3.1" 1235 | source = "registry+https://github.com/rust-lang/crates.io-index" 1236 | checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" 1237 | dependencies = [ 1238 | "rand_core 0.6.3", 1239 | ] 1240 | 1241 | [[package]] 1242 | name = "redox_syscall" 1243 | version = "0.2.9" 1244 | source = "registry+https://github.com/rust-lang/crates.io-index" 1245 | checksum = "5ab49abadf3f9e1c4bc499e8845e152ad87d2ad2d30371841171169e9d75feee" 1246 | dependencies = [ 1247 | "bitflags", 1248 | ] 1249 | 1250 | [[package]] 1251 | name = "redox_users" 1252 | version = "0.4.0" 1253 | source = "registry+https://github.com/rust-lang/crates.io-index" 1254 | checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" 1255 | dependencies = [ 1256 | "getrandom 0.2.3", 1257 | "redox_syscall", 1258 | ] 1259 | 1260 | [[package]] 1261 | name = "regex" 1262 | version = "1.5.4" 1263 | source = "registry+https://github.com/rust-lang/crates.io-index" 1264 | checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" 1265 | dependencies = [ 1266 | "aho-corasick", 1267 | "memchr", 1268 | "regex-syntax", 1269 | ] 1270 | 1271 | [[package]] 1272 | name = "regex-syntax" 1273 | version = "0.6.25" 1274 | source = "registry+https://github.com/rust-lang/crates.io-index" 1275 | checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" 1276 | 1277 | [[package]] 1278 | name = "remove_dir_all" 1279 | version = "0.5.3" 1280 | source = "registry+https://github.com/rust-lang/crates.io-index" 1281 | checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" 1282 | dependencies = [ 1283 | "winapi", 1284 | ] 1285 | 1286 | [[package]] 1287 | name = "reqwest" 1288 | version = "0.11.4" 1289 | source = "registry+https://github.com/rust-lang/crates.io-index" 1290 | checksum = "246e9f61b9bb77df069a947682be06e31ac43ea37862e244a69f177694ea6d22" 1291 | dependencies = [ 1292 | "base64", 1293 | "bytes", 1294 | "encoding_rs", 1295 | "futures-core", 1296 | "futures-util", 1297 | "http", 1298 | "http-body", 1299 | "hyper", 1300 | "hyper-tls", 1301 | "ipnet", 1302 | "js-sys", 1303 | "lazy_static", 1304 | "log", 1305 | "mime", 1306 | "native-tls", 1307 | "percent-encoding", 1308 | "pin-project-lite", 1309 | "serde", 1310 | "serde_urlencoded", 1311 | "tokio", 1312 | "tokio-native-tls", 1313 | "url", 1314 | "wasm-bindgen", 1315 | "wasm-bindgen-futures", 1316 | "web-sys", 1317 | "winreg", 1318 | ] 1319 | 1320 | [[package]] 1321 | name = "rustc-hash" 1322 | version = "1.1.0" 1323 | source = "registry+https://github.com/rust-lang/crates.io-index" 1324 | checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" 1325 | 1326 | [[package]] 1327 | name = "rustversion" 1328 | version = "1.0.5" 1329 | source = "registry+https://github.com/rust-lang/crates.io-index" 1330 | checksum = "61b3909d758bb75c79f23d4736fac9433868679d3ad2ea7a61e3c25cfda9a088" 1331 | 1332 | [[package]] 1333 | name = "ryu" 1334 | version = "1.0.5" 1335 | source = "registry+https://github.com/rust-lang/crates.io-index" 1336 | checksum = "71d301d4193d031abdd79ff7e3dd721168a9572ef3fe51a1517aba235bd8f86e" 1337 | 1338 | [[package]] 1339 | name = "same-file" 1340 | version = "1.0.6" 1341 | source = "registry+https://github.com/rust-lang/crates.io-index" 1342 | checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" 1343 | dependencies = [ 1344 | "winapi-util", 1345 | ] 1346 | 1347 | [[package]] 1348 | name = "schannel" 1349 | version = "0.1.19" 1350 | source = "registry+https://github.com/rust-lang/crates.io-index" 1351 | checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" 1352 | dependencies = [ 1353 | "lazy_static", 1354 | "winapi", 1355 | ] 1356 | 1357 | [[package]] 1358 | name = "scopeguard" 1359 | version = "1.1.0" 1360 | source = "registry+https://github.com/rust-lang/crates.io-index" 1361 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 1362 | 1363 | [[package]] 1364 | name = "security-framework" 1365 | version = "2.3.1" 1366 | source = "registry+https://github.com/rust-lang/crates.io-index" 1367 | checksum = "23a2ac85147a3a11d77ecf1bc7166ec0b92febfa4461c37944e180f319ece467" 1368 | dependencies = [ 1369 | "bitflags", 1370 | "core-foundation", 1371 | "core-foundation-sys", 1372 | "libc", 1373 | "security-framework-sys", 1374 | ] 1375 | 1376 | [[package]] 1377 | name = "security-framework-sys" 1378 | version = "2.3.0" 1379 | source = "registry+https://github.com/rust-lang/crates.io-index" 1380 | checksum = "7e4effb91b4b8b6fb7732e670b6cee160278ff8e6bf485c7805d9e319d76e284" 1381 | dependencies = [ 1382 | "core-foundation-sys", 1383 | "libc", 1384 | ] 1385 | 1386 | [[package]] 1387 | name = "semver" 1388 | version = "0.9.0" 1389 | source = "registry+https://github.com/rust-lang/crates.io-index" 1390 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 1391 | dependencies = [ 1392 | "semver-parser", 1393 | ] 1394 | 1395 | [[package]] 1396 | name = "semver-parser" 1397 | version = "0.7.0" 1398 | source = "registry+https://github.com/rust-lang/crates.io-index" 1399 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 1400 | 1401 | [[package]] 1402 | name = "serde" 1403 | version = "1.0.126" 1404 | source = "registry+https://github.com/rust-lang/crates.io-index" 1405 | checksum = "ec7505abeacaec74ae4778d9d9328fe5a5d04253220a85c4ee022239fc996d03" 1406 | 1407 | [[package]] 1408 | name = "serde_derive" 1409 | version = "1.0.126" 1410 | source = "registry+https://github.com/rust-lang/crates.io-index" 1411 | checksum = "963a7dbc9895aeac7ac90e74f34a5d5261828f79df35cbed41e10189d3804d43" 1412 | dependencies = [ 1413 | "proc-macro2", 1414 | "quote", 1415 | "syn", 1416 | ] 1417 | 1418 | [[package]] 1419 | name = "serde_json" 1420 | version = "1.0.64" 1421 | source = "registry+https://github.com/rust-lang/crates.io-index" 1422 | checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" 1423 | dependencies = [ 1424 | "itoa", 1425 | "ryu", 1426 | "serde", 1427 | ] 1428 | 1429 | [[package]] 1430 | name = "serde_urlencoded" 1431 | version = "0.7.0" 1432 | source = "registry+https://github.com/rust-lang/crates.io-index" 1433 | checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" 1434 | dependencies = [ 1435 | "form_urlencoded", 1436 | "itoa", 1437 | "ryu", 1438 | "serde", 1439 | ] 1440 | 1441 | [[package]] 1442 | name = "shlex" 1443 | version = "0.1.1" 1444 | source = "registry+https://github.com/rust-lang/crates.io-index" 1445 | checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" 1446 | 1447 | [[package]] 1448 | name = "signal-hook-registry" 1449 | version = "1.4.0" 1450 | source = "registry+https://github.com/rust-lang/crates.io-index" 1451 | checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" 1452 | dependencies = [ 1453 | "libc", 1454 | ] 1455 | 1456 | [[package]] 1457 | name = "slab" 1458 | version = "0.4.3" 1459 | source = "registry+https://github.com/rust-lang/crates.io-index" 1460 | checksum = "f173ac3d1a7e3b28003f40de0b5ce7fe2710f9b9dc3fc38664cebee46b3b6527" 1461 | 1462 | [[package]] 1463 | name = "slog" 1464 | version = "2.7.0" 1465 | source = "registry+https://github.com/rust-lang/crates.io-index" 1466 | checksum = "8347046d4ebd943127157b94d63abb990fcf729dc4e9978927fdf4ac3c998d06" 1467 | 1468 | [[package]] 1469 | name = "slog-term" 1470 | version = "2.8.0" 1471 | source = "registry+https://github.com/rust-lang/crates.io-index" 1472 | checksum = "95c1e7e5aab61ced6006149ea772770b84a0d16ce0f7885def313e4829946d76" 1473 | dependencies = [ 1474 | "atty", 1475 | "chrono", 1476 | "slog", 1477 | "term", 1478 | "thread_local", 1479 | ] 1480 | 1481 | [[package]] 1482 | name = "smallvec" 1483 | version = "1.6.1" 1484 | source = "registry+https://github.com/rust-lang/crates.io-index" 1485 | checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" 1486 | 1487 | [[package]] 1488 | name = "socket2" 1489 | version = "0.4.0" 1490 | source = "registry+https://github.com/rust-lang/crates.io-index" 1491 | checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" 1492 | dependencies = [ 1493 | "libc", 1494 | "winapi", 1495 | ] 1496 | 1497 | [[package]] 1498 | name = "syn" 1499 | version = "1.0.74" 1500 | source = "registry+https://github.com/rust-lang/crates.io-index" 1501 | checksum = "1873d832550d4588c3dbc20f01361ab00bfe741048f71e3fecf145a7cc18b29c" 1502 | dependencies = [ 1503 | "proc-macro2", 1504 | "quote", 1505 | "unicode-xid", 1506 | ] 1507 | 1508 | [[package]] 1509 | name = "tempfile" 1510 | version = "3.2.0" 1511 | source = "registry+https://github.com/rust-lang/crates.io-index" 1512 | checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" 1513 | dependencies = [ 1514 | "cfg-if", 1515 | "libc", 1516 | "rand 0.8.4", 1517 | "redox_syscall", 1518 | "remove_dir_all", 1519 | "winapi", 1520 | ] 1521 | 1522 | [[package]] 1523 | name = "term" 1524 | version = "0.7.0" 1525 | source = "registry+https://github.com/rust-lang/crates.io-index" 1526 | checksum = "c59df8ac95d96ff9bede18eb7300b0fda5e5d8d90960e76f8e14ae765eedbf1f" 1527 | dependencies = [ 1528 | "dirs-next", 1529 | "rustversion", 1530 | "winapi", 1531 | ] 1532 | 1533 | [[package]] 1534 | name = "thiserror" 1535 | version = "1.0.26" 1536 | source = "registry+https://github.com/rust-lang/crates.io-index" 1537 | checksum = "93119e4feac1cbe6c798c34d3a53ea0026b0b1de6a120deef895137c0529bfe2" 1538 | dependencies = [ 1539 | "thiserror-impl", 1540 | ] 1541 | 1542 | [[package]] 1543 | name = "thiserror-impl" 1544 | version = "1.0.26" 1545 | source = "registry+https://github.com/rust-lang/crates.io-index" 1546 | checksum = "060d69a0afe7796bf42e9e2ff91f5ee691fb15c53d38b4b62a9a53eb23164745" 1547 | dependencies = [ 1548 | "proc-macro2", 1549 | "quote", 1550 | "syn", 1551 | ] 1552 | 1553 | [[package]] 1554 | name = "thread_local" 1555 | version = "1.1.3" 1556 | source = "registry+https://github.com/rust-lang/crates.io-index" 1557 | checksum = "8018d24e04c95ac8790716a5987d0fec4f8b27249ffa0f7d33f1369bdfb88cbd" 1558 | dependencies = [ 1559 | "once_cell", 1560 | ] 1561 | 1562 | [[package]] 1563 | name = "tikv-client" 1564 | version = "0.0.0" 1565 | dependencies = [ 1566 | "lazy_static", 1567 | "neon", 1568 | "once_cell", 1569 | "tikv-client 0.1.0", 1570 | "tokio", 1571 | ] 1572 | 1573 | [[package]] 1574 | name = "tikv-client" 1575 | version = "0.1.0" 1576 | source = "git+https://github.com/tikv/client-rust.git?branch=master#c14f23a545cc5cce7a5a5a4e51442e39617ec63d" 1577 | dependencies = [ 1578 | "async-recursion", 1579 | "async-trait", 1580 | "derive-new", 1581 | "fail", 1582 | "futures 0.3.15", 1583 | "futures-timer", 1584 | "grpcio", 1585 | "lazy_static", 1586 | "log", 1587 | "prometheus", 1588 | "rand 0.8.4", 1589 | "regex", 1590 | "serde", 1591 | "serde_derive", 1592 | "slog", 1593 | "slog-term", 1594 | "thiserror", 1595 | "tikv-client-common", 1596 | "tikv-client-pd", 1597 | "tikv-client-proto", 1598 | "tikv-client-store", 1599 | "tokio", 1600 | ] 1601 | 1602 | [[package]] 1603 | name = "tikv-client-common" 1604 | version = "0.1.0" 1605 | source = "git+https://github.com/tikv/client-rust.git?branch=master#c14f23a545cc5cce7a5a5a4e51442e39617ec63d" 1606 | dependencies = [ 1607 | "futures 0.3.15", 1608 | "grpcio", 1609 | "lazy_static", 1610 | "log", 1611 | "regex", 1612 | "thiserror", 1613 | "tikv-client-proto", 1614 | "tokio", 1615 | ] 1616 | 1617 | [[package]] 1618 | name = "tikv-client-pd" 1619 | version = "0.1.0" 1620 | source = "git+https://github.com/tikv/client-rust.git?branch=master#c14f23a545cc5cce7a5a5a4e51442e39617ec63d" 1621 | dependencies = [ 1622 | "async-trait", 1623 | "futures 0.3.15", 1624 | "grpcio", 1625 | "log", 1626 | "tikv-client-common", 1627 | "tikv-client-proto", 1628 | ] 1629 | 1630 | [[package]] 1631 | name = "tikv-client-proto" 1632 | version = "0.1.0" 1633 | source = "git+https://github.com/tikv/client-rust.git?branch=master#c14f23a545cc5cce7a5a5a4e51442e39617ec63d" 1634 | dependencies = [ 1635 | "futures 0.3.15", 1636 | "grpcio", 1637 | "lazy_static", 1638 | "prost", 1639 | "prost-derive", 1640 | "protobuf", 1641 | "protobuf-build", 1642 | ] 1643 | 1644 | [[package]] 1645 | name = "tikv-client-store" 1646 | version = "0.1.0" 1647 | source = "git+https://github.com/tikv/client-rust.git?branch=master#c14f23a545cc5cce7a5a5a4e51442e39617ec63d" 1648 | dependencies = [ 1649 | "async-trait", 1650 | "derive-new", 1651 | "futures 0.3.15", 1652 | "grpcio", 1653 | "log", 1654 | "tikv-client-common", 1655 | "tikv-client-proto", 1656 | ] 1657 | 1658 | [[package]] 1659 | name = "time" 1660 | version = "0.1.43" 1661 | source = "registry+https://github.com/rust-lang/crates.io-index" 1662 | checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" 1663 | dependencies = [ 1664 | "libc", 1665 | "winapi", 1666 | ] 1667 | 1668 | [[package]] 1669 | name = "tinyvec" 1670 | version = "1.3.1" 1671 | source = "registry+https://github.com/rust-lang/crates.io-index" 1672 | checksum = "848a1e1181b9f6753b5e96a092749e29b11d19ede67dfbbd6c7dc7e0f49b5338" 1673 | dependencies = [ 1674 | "tinyvec_macros", 1675 | ] 1676 | 1677 | [[package]] 1678 | name = "tinyvec_macros" 1679 | version = "0.1.0" 1680 | source = "registry+https://github.com/rust-lang/crates.io-index" 1681 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 1682 | 1683 | [[package]] 1684 | name = "tokio" 1685 | version = "1.9.0" 1686 | source = "registry+https://github.com/rust-lang/crates.io-index" 1687 | checksum = "4b7b349f11a7047e6d1276853e612d152f5e8a352c61917887cc2169e2366b4c" 1688 | dependencies = [ 1689 | "autocfg", 1690 | "bytes", 1691 | "libc", 1692 | "memchr", 1693 | "mio", 1694 | "num_cpus", 1695 | "once_cell", 1696 | "parking_lot", 1697 | "pin-project-lite", 1698 | "signal-hook-registry", 1699 | "tokio-macros", 1700 | "winapi", 1701 | ] 1702 | 1703 | [[package]] 1704 | name = "tokio-macros" 1705 | version = "1.3.0" 1706 | source = "registry+https://github.com/rust-lang/crates.io-index" 1707 | checksum = "54473be61f4ebe4efd09cec9bd5d16fa51d70ea0192213d754d2d500457db110" 1708 | dependencies = [ 1709 | "proc-macro2", 1710 | "quote", 1711 | "syn", 1712 | ] 1713 | 1714 | [[package]] 1715 | name = "tokio-native-tls" 1716 | version = "0.3.0" 1717 | source = "registry+https://github.com/rust-lang/crates.io-index" 1718 | checksum = "f7d995660bd2b7f8c1568414c1126076c13fbb725c40112dc0120b78eb9b717b" 1719 | dependencies = [ 1720 | "native-tls", 1721 | "tokio", 1722 | ] 1723 | 1724 | [[package]] 1725 | name = "tokio-util" 1726 | version = "0.6.7" 1727 | source = "registry+https://github.com/rust-lang/crates.io-index" 1728 | checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" 1729 | dependencies = [ 1730 | "bytes", 1731 | "futures-core", 1732 | "futures-sink", 1733 | "log", 1734 | "pin-project-lite", 1735 | "tokio", 1736 | ] 1737 | 1738 | [[package]] 1739 | name = "tower-service" 1740 | version = "0.3.1" 1741 | source = "registry+https://github.com/rust-lang/crates.io-index" 1742 | checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" 1743 | 1744 | [[package]] 1745 | name = "tracing" 1746 | version = "0.1.26" 1747 | source = "registry+https://github.com/rust-lang/crates.io-index" 1748 | checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" 1749 | dependencies = [ 1750 | "cfg-if", 1751 | "pin-project-lite", 1752 | "tracing-core", 1753 | ] 1754 | 1755 | [[package]] 1756 | name = "tracing-core" 1757 | version = "0.1.18" 1758 | source = "registry+https://github.com/rust-lang/crates.io-index" 1759 | checksum = "a9ff14f98b1a4b289c6248a023c1c2fa1491062964e9fed67ab29c4e4da4a052" 1760 | dependencies = [ 1761 | "lazy_static", 1762 | ] 1763 | 1764 | [[package]] 1765 | name = "try-lock" 1766 | version = "0.2.3" 1767 | source = "registry+https://github.com/rust-lang/crates.io-index" 1768 | checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" 1769 | 1770 | [[package]] 1771 | name = "unicode-bidi" 1772 | version = "0.3.5" 1773 | source = "registry+https://github.com/rust-lang/crates.io-index" 1774 | checksum = "eeb8be209bb1c96b7c177c7420d26e04eccacb0eeae6b980e35fcb74678107e0" 1775 | dependencies = [ 1776 | "matches", 1777 | ] 1778 | 1779 | [[package]] 1780 | name = "unicode-normalization" 1781 | version = "0.1.19" 1782 | source = "registry+https://github.com/rust-lang/crates.io-index" 1783 | checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" 1784 | dependencies = [ 1785 | "tinyvec", 1786 | ] 1787 | 1788 | [[package]] 1789 | name = "unicode-segmentation" 1790 | version = "1.8.0" 1791 | source = "registry+https://github.com/rust-lang/crates.io-index" 1792 | checksum = "8895849a949e7845e06bd6dc1aa51731a103c42707010a5b591c0038fb73385b" 1793 | 1794 | [[package]] 1795 | name = "unicode-xid" 1796 | version = "0.2.2" 1797 | source = "registry+https://github.com/rust-lang/crates.io-index" 1798 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 1799 | 1800 | [[package]] 1801 | name = "url" 1802 | version = "2.2.2" 1803 | source = "registry+https://github.com/rust-lang/crates.io-index" 1804 | checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" 1805 | dependencies = [ 1806 | "form_urlencoded", 1807 | "idna", 1808 | "matches", 1809 | "percent-encoding", 1810 | ] 1811 | 1812 | [[package]] 1813 | name = "vcpkg" 1814 | version = "0.2.15" 1815 | source = "registry+https://github.com/rust-lang/crates.io-index" 1816 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 1817 | 1818 | [[package]] 1819 | name = "version_check" 1820 | version = "0.9.3" 1821 | source = "registry+https://github.com/rust-lang/crates.io-index" 1822 | checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" 1823 | 1824 | [[package]] 1825 | name = "walkdir" 1826 | version = "2.3.2" 1827 | source = "registry+https://github.com/rust-lang/crates.io-index" 1828 | checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" 1829 | dependencies = [ 1830 | "same-file", 1831 | "winapi", 1832 | "winapi-util", 1833 | ] 1834 | 1835 | [[package]] 1836 | name = "want" 1837 | version = "0.3.0" 1838 | source = "registry+https://github.com/rust-lang/crates.io-index" 1839 | checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" 1840 | dependencies = [ 1841 | "log", 1842 | "try-lock", 1843 | ] 1844 | 1845 | [[package]] 1846 | name = "wasi" 1847 | version = "0.9.0+wasi-snapshot-preview1" 1848 | source = "registry+https://github.com/rust-lang/crates.io-index" 1849 | checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" 1850 | 1851 | [[package]] 1852 | name = "wasi" 1853 | version = "0.10.2+wasi-snapshot-preview1" 1854 | source = "registry+https://github.com/rust-lang/crates.io-index" 1855 | checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 1856 | 1857 | [[package]] 1858 | name = "wasm-bindgen" 1859 | version = "0.2.74" 1860 | source = "registry+https://github.com/rust-lang/crates.io-index" 1861 | checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" 1862 | dependencies = [ 1863 | "cfg-if", 1864 | "serde", 1865 | "serde_json", 1866 | "wasm-bindgen-macro", 1867 | ] 1868 | 1869 | [[package]] 1870 | name = "wasm-bindgen-backend" 1871 | version = "0.2.74" 1872 | source = "registry+https://github.com/rust-lang/crates.io-index" 1873 | checksum = "3b33f6a0694ccfea53d94db8b2ed1c3a8a4c86dd936b13b9f0a15ec4a451b900" 1874 | dependencies = [ 1875 | "bumpalo", 1876 | "lazy_static", 1877 | "log", 1878 | "proc-macro2", 1879 | "quote", 1880 | "syn", 1881 | "wasm-bindgen-shared", 1882 | ] 1883 | 1884 | [[package]] 1885 | name = "wasm-bindgen-futures" 1886 | version = "0.4.24" 1887 | source = "registry+https://github.com/rust-lang/crates.io-index" 1888 | checksum = "5fba7978c679d53ce2d0ac80c8c175840feb849a161664365d1287b41f2e67f1" 1889 | dependencies = [ 1890 | "cfg-if", 1891 | "js-sys", 1892 | "wasm-bindgen", 1893 | "web-sys", 1894 | ] 1895 | 1896 | [[package]] 1897 | name = "wasm-bindgen-macro" 1898 | version = "0.2.74" 1899 | source = "registry+https://github.com/rust-lang/crates.io-index" 1900 | checksum = "088169ca61430fe1e58b8096c24975251700e7b1f6fd91cc9d59b04fb9b18bd4" 1901 | dependencies = [ 1902 | "quote", 1903 | "wasm-bindgen-macro-support", 1904 | ] 1905 | 1906 | [[package]] 1907 | name = "wasm-bindgen-macro-support" 1908 | version = "0.2.74" 1909 | source = "registry+https://github.com/rust-lang/crates.io-index" 1910 | checksum = "be2241542ff3d9f241f5e2cb6dd09b37efe786df8851c54957683a49f0987a97" 1911 | dependencies = [ 1912 | "proc-macro2", 1913 | "quote", 1914 | "syn", 1915 | "wasm-bindgen-backend", 1916 | "wasm-bindgen-shared", 1917 | ] 1918 | 1919 | [[package]] 1920 | name = "wasm-bindgen-shared" 1921 | version = "0.2.74" 1922 | source = "registry+https://github.com/rust-lang/crates.io-index" 1923 | checksum = "d7cff876b8f18eed75a66cf49b65e7f967cb354a7aa16003fb55dbfd25b44b4f" 1924 | 1925 | [[package]] 1926 | name = "web-sys" 1927 | version = "0.3.51" 1928 | source = "registry+https://github.com/rust-lang/crates.io-index" 1929 | checksum = "e828417b379f3df7111d3a2a9e5753706cae29c41f7c4029ee9fd77f3e09e582" 1930 | dependencies = [ 1931 | "js-sys", 1932 | "wasm-bindgen", 1933 | ] 1934 | 1935 | [[package]] 1936 | name = "which" 1937 | version = "4.1.0" 1938 | source = "registry+https://github.com/rust-lang/crates.io-index" 1939 | checksum = "b55551e42cbdf2ce2bedd2203d0cc08dba002c27510f86dab6d0ce304cba3dfe" 1940 | dependencies = [ 1941 | "either", 1942 | "libc", 1943 | ] 1944 | 1945 | [[package]] 1946 | name = "winapi" 1947 | version = "0.3.9" 1948 | source = "registry+https://github.com/rust-lang/crates.io-index" 1949 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1950 | dependencies = [ 1951 | "winapi-i686-pc-windows-gnu", 1952 | "winapi-x86_64-pc-windows-gnu", 1953 | ] 1954 | 1955 | [[package]] 1956 | name = "winapi-i686-pc-windows-gnu" 1957 | version = "0.4.0" 1958 | source = "registry+https://github.com/rust-lang/crates.io-index" 1959 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 1960 | 1961 | [[package]] 1962 | name = "winapi-util" 1963 | version = "0.1.5" 1964 | source = "registry+https://github.com/rust-lang/crates.io-index" 1965 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 1966 | dependencies = [ 1967 | "winapi", 1968 | ] 1969 | 1970 | [[package]] 1971 | name = "winapi-x86_64-pc-windows-gnu" 1972 | version = "0.4.0" 1973 | source = "registry+https://github.com/rust-lang/crates.io-index" 1974 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 1975 | 1976 | [[package]] 1977 | name = "winreg" 1978 | version = "0.7.0" 1979 | source = "registry+https://github.com/rust-lang/crates.io-index" 1980 | checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" 1981 | dependencies = [ 1982 | "winapi", 1983 | ] 1984 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "tikv-client" 3 | version = "0.0.0" 4 | description = "A TiKV client in Node.js." 5 | authors = ["Mossaka"] 6 | license = "Apache-2.0" 7 | edition = "2018" 8 | exclude = ["index.node"] 9 | 10 | [lib] 11 | crate-type = ["cdylib"] 12 | 13 | [dependencies.neon] 14 | version = "0.8" 15 | default-features = false 16 | features = ["napi-6", "event-queue-api"] 17 | 18 | [dependencies] 19 | tikv-client = { git="https://github.com/tikv/client-rust.git", branch="master" } 20 | tokio = { version="1.6.1", features=["full"] } 21 | lazy_static = "1" 22 | once_cell = "1.8.0" 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # client-node 2 | 3 | **client-node:** A TiKV client in Node.js. 4 | 5 | This project was bootstrapped by [create-neon](https://www.npmjs.com/package/create-neon). 6 | 7 | ## Installing client-node 8 | 9 | Installing client-node requires a [supported version of Node and Rust](https://github.com/neon-bindings/neon#platform-support). 10 | 11 | You can install the project with npm. In the project directory, run: 12 | 13 | ```sh 14 | $ npm install 15 | ``` 16 | 17 | This fully installs the project, including installing any dependencies and running the build. 18 | 19 | ## Building client-node 20 | 21 | If you have already installed the project and only want to run the build, run: 22 | 23 | ```sh 24 | $ npm run build 25 | ``` 26 | 27 | This command uses the [cargo-cp-artifact](https://github.com/neon-bindings/cargo-cp-artifact) utility to run the Rust build and copy the built library into `./index.node`. 28 | 29 | ## Exploring client-node 30 | 31 | After building client-node, you can explore its exports at the Node REPL: 32 | 33 | ```sh 34 | $ npm install 35 | $ node transaction_app.js 36 | v4 37 | v3 38 | [ 'k1', 'v1' ] 39 | [ 'k4', 'v4' ] 40 | ``` 41 | 42 | ## Available Scripts 43 | 44 | In the project directory, you can run: 45 | 46 | ### `npm install` 47 | 48 | Installs the project, including running `npm run build`. 49 | 50 | ### `npm build` 51 | 52 | Builds the Node addon (`index.node`) from source. 53 | 54 | ### `npm test` 55 | 56 | Runs the unit tests by calling `cargo test`. You can learn more about [adding tests to your Rust code](https://doc.rust-lang.org/book/ch11-01-writing-tests.html) from the [Rust book](https://doc.rust-lang.org/book/). 57 | -------------------------------------------------------------------------------- /examples/error.js: -------------------------------------------------------------------------------- 1 | const assert = require("assert"); 2 | const { OperationAfterCommitError } = require("../dist/error"); 3 | 4 | // const tikv = require("../tikv_client/asynchronous"); 5 | 6 | // (async () => { 7 | // const client = await new tikv.TransactionClient("127.0.0.1:2379"); 8 | // const txn = await client.begin(true); 9 | // await txn.put("k1", "v1"); 10 | // await txn.commit(); 11 | // txn.get("k1").then(v => console.log(v)).catch(e => console.log(e)); 12 | // })(); 13 | 14 | const tikv = require("../dist"); 15 | 16 | const client = new tikv.TransactionClient("127.0.0.1:2379"); 17 | const txn = client.begin(true); 18 | txn.put("k1", "v1"); 19 | txn.commit(); 20 | assert.throws(() => txn.get("k1"), OperationAfterCommitError); 21 | -------------------------------------------------------------------------------- /examples/raw_app.js: -------------------------------------------------------------------------------- 1 | const tikv = require("../dist/asynchronous"); 2 | 3 | (async () => { 4 | const client = await new tikv.RawClient("127.0.0.1:2379"); 5 | await client.put("k1", "v1", "default"); 6 | await client.put("k2", "v2", "default"); 7 | await client.put("k3", "v3", "default"); 8 | await client.put("k4", "v4", "default"); 9 | value = await client.get("k1", "default"); 10 | console.log(value.toString()); 11 | value = await client.get("k2", "default"); 12 | console.log(value.toString()); 13 | value = await client.get("k3", "default"); 14 | console.log(value.toString()); 15 | await client.delete("k4", "default"); 16 | await client.get("k4", "default"); 17 | 18 | await client.batch_put( 19 | [ 20 | ["k5", "v5"], 21 | ["k6", "v6"], 22 | ], 23 | "default" 24 | ); 25 | await client.batch_delete(["k1", "k2", "k5"], "default"); 26 | values = await client.batch_get( 27 | ["k1", "k2", "k3", "k4", "k5", "k6"], 28 | "default" 29 | ); 30 | 31 | console.log(values); 32 | })(); 33 | -------------------------------------------------------------------------------- /examples/sync_raw_app.js: -------------------------------------------------------------------------------- 1 | const tikv = require("../dist"); 2 | 3 | const client = new tikv.RawClient("127.0.0.1:2379"); 4 | 5 | client.put("k1", "v1", "default"); 6 | client.put("k2", "v2", "default"); 7 | client.put("k3", "v3", "default"); 8 | 9 | const v1 = client.get("k1", "default"); 10 | const v2 = client.get("k2", "default"); 11 | const v3 = client.get("k3", "default"); 12 | 13 | console.log(v1, v2, v3); 14 | 15 | client.delete("k1", "default"); 16 | client.delete("k2", "default"); 17 | 18 | const v1_ = client.get("k1", "default"); 19 | const v2_ = client.get("k2", "default"); 20 | 21 | console.log(v1_, v2_, v3); 22 | 23 | client.batch_put( 24 | [ 25 | ["k3", "k4", "k5"], 26 | ["v3", "v4", "v5"], 27 | ], 28 | "default" 29 | ); 30 | const vals = client.batch_get(["k3", "k4", "k5"], "default"); 31 | for (let i = 0; i < vals.length; i++) { 32 | console.log(vals[i]); 33 | } 34 | 35 | const scan_vals = client.scan("k1", "k5", 10, true, true, "default"); 36 | for (let i = 0; i < scan_vals.length; i++) { 37 | console.log(scan_vals[i]); 38 | } 39 | -------------------------------------------------------------------------------- /examples/sync_transaction_app.js: -------------------------------------------------------------------------------- 1 | const tikv = require("../dist"); 2 | 3 | const client = new tikv.TransactionClient("127.0.0.1:2379"); 4 | const txn = client.begin(true); 5 | txn.put("k1", "v1"); 6 | txn.put("k2", "v2"); 7 | txn.put("k3", "v3"); 8 | txn.put("k4", "v4"); 9 | const v4 = txn.get("k4"); 10 | txn.commit(); 11 | console.log(v4); 12 | const snapshot = client.snapshot(client.current_timestamp(), true); 13 | const result = snapshot.get("k3"); 14 | console.log(result); 15 | const values = snapshot.batch_get(["k1", "k4"]); 16 | values.forEach((element) => { 17 | console.log(element); 18 | }); 19 | 20 | const result2 = snapshot.scan("k1", "k2", 10, true, true); 21 | result2.forEach((element) => { 22 | console.log(element); 23 | }); 24 | -------------------------------------------------------------------------------- /examples/transaction_app.js: -------------------------------------------------------------------------------- 1 | const tikv = require("../dist/asynchronous"); 2 | 3 | (async () => { 4 | const client = await new tikv.TransactionClient("127.0.0.1:2379"); 5 | const txn = await client.begin(true); 6 | await txn.put("k1", "v1"); 7 | await txn.put("k2", "v2"); 8 | await txn.put("k3", "v3"); 9 | await txn.put("k4", "v4"); 10 | const val = await txn.get("k4"); 11 | await txn.commit(); 12 | console.log(val); 13 | const snapshot = await client.snapshot( 14 | await client.current_timestamp(), 15 | true 16 | ); 17 | const result = await snapshot.get("k3"); 18 | console.log(result); 19 | const values = await snapshot.batch_get(["k1", "k4"]); 20 | values.forEach((element) => { 21 | console.log(element); 22 | }); 23 | 24 | const result2 = await snapshot.scan("k1", "k2", 10, false, false); 25 | result2.forEach((element) => { 26 | console.log(element); 27 | }); 28 | })(); 29 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tikv-client", 3 | "version": "0.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "tikv-client", 9 | "version": "0.0.0", 10 | "hasInstallScript": true, 11 | "license": "Apache-2.0", 12 | "dependencies": { 13 | "deasync": "^0.1.21" 14 | }, 15 | "devDependencies": { 16 | "@types/node": "^16.7.10", 17 | "cargo-cp-artifact": "^0.1", 18 | "jsdoc": "^3.6.7", 19 | "typescript": "^4.4.2" 20 | } 21 | }, 22 | "node_modules/@babel/parser": { 23 | "version": "7.15.3", 24 | "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.15.3.tgz", 25 | "integrity": "sha512-O0L6v/HvqbdJawj0iBEfVQMc3/6WP+AeOsovsIgBFyJaG+W2w7eqvZB7puddATmWuARlm1SX7DwxJ/JJUnDpEA==", 26 | "dev": true, 27 | "bin": { 28 | "parser": "bin/babel-parser.js" 29 | }, 30 | "engines": { 31 | "node": ">=6.0.0" 32 | } 33 | }, 34 | "node_modules/@types/node": { 35 | "version": "16.7.10", 36 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.10.tgz", 37 | "integrity": "sha512-S63Dlv4zIPb8x6MMTgDq5WWRJQe56iBEY0O3SOFA9JrRienkOVDXSXBjjJw6HTNQYSE2JI6GMCR6LVbIMHJVvA==", 38 | "dev": true 39 | }, 40 | "node_modules/argparse": { 41 | "version": "1.0.10", 42 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 43 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 44 | "dev": true, 45 | "dependencies": { 46 | "sprintf-js": "~1.0.2" 47 | } 48 | }, 49 | "node_modules/bindings": { 50 | "version": "1.5.0", 51 | "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", 52 | "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", 53 | "dependencies": { 54 | "file-uri-to-path": "1.0.0" 55 | } 56 | }, 57 | "node_modules/bluebird": { 58 | "version": "3.7.2", 59 | "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", 60 | "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", 61 | "dev": true 62 | }, 63 | "node_modules/cargo-cp-artifact": { 64 | "version": "0.1.4", 65 | "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.4.tgz", 66 | "integrity": "sha512-34yUas8aUENHGdk6JhLkV4ol0GLtP78YgqpsRDmmnpADy9JoTg/DgKM3CRHAeozTRNhKoPaRFhV+BxoqkmoKUA==", 67 | "dev": true, 68 | "bin": { 69 | "cargo-cp-artifact": "bin/cargo-cp-artifact.js" 70 | } 71 | }, 72 | "node_modules/catharsis": { 73 | "version": "0.9.0", 74 | "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", 75 | "integrity": "sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A==", 76 | "dev": true, 77 | "dependencies": { 78 | "lodash": "^4.17.15" 79 | }, 80 | "engines": { 81 | "node": ">= 10" 82 | } 83 | }, 84 | "node_modules/deasync": { 85 | "version": "0.1.21", 86 | "resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.21.tgz", 87 | "integrity": "sha512-kUmM8Y+PZpMpQ+B4AuOW9k2Pfx/mSupJtxOsLzmnHY2WqZUYRFccFn2RhzPAqt3Xb+sorK/badW2D4zNzqZz5w==", 88 | "hasInstallScript": true, 89 | "dependencies": { 90 | "bindings": "^1.5.0", 91 | "node-addon-api": "^1.7.1" 92 | }, 93 | "engines": { 94 | "node": ">=0.11.0" 95 | } 96 | }, 97 | "node_modules/entities": { 98 | "version": "2.0.3", 99 | "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", 100 | "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", 101 | "dev": true 102 | }, 103 | "node_modules/escape-string-regexp": { 104 | "version": "2.0.0", 105 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", 106 | "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", 107 | "dev": true, 108 | "engines": { 109 | "node": ">=8" 110 | } 111 | }, 112 | "node_modules/file-uri-to-path": { 113 | "version": "1.0.0", 114 | "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", 115 | "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" 116 | }, 117 | "node_modules/graceful-fs": { 118 | "version": "4.2.8", 119 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", 120 | "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", 121 | "dev": true 122 | }, 123 | "node_modules/js2xmlparser": { 124 | "version": "4.0.1", 125 | "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.1.tgz", 126 | "integrity": "sha512-KrPTolcw6RocpYjdC7pL7v62e55q7qOMHvLX1UCLc5AAS8qeJ6nukarEJAF2KL2PZxlbGueEbINqZR2bDe/gUw==", 127 | "dev": true, 128 | "dependencies": { 129 | "xmlcreate": "^2.0.3" 130 | } 131 | }, 132 | "node_modules/jsdoc": { 133 | "version": "3.6.7", 134 | "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.7.tgz", 135 | "integrity": "sha512-sxKt7h0vzCd+3Y81Ey2qinupL6DpRSZJclS04ugHDNmRUXGzqicMJ6iwayhSA0S0DwwX30c5ozyUthr1QKF6uw==", 136 | "dev": true, 137 | "dependencies": { 138 | "@babel/parser": "^7.9.4", 139 | "bluebird": "^3.7.2", 140 | "catharsis": "^0.9.0", 141 | "escape-string-regexp": "^2.0.0", 142 | "js2xmlparser": "^4.0.1", 143 | "klaw": "^3.0.0", 144 | "markdown-it": "^10.0.0", 145 | "markdown-it-anchor": "^5.2.7", 146 | "marked": "^2.0.3", 147 | "mkdirp": "^1.0.4", 148 | "requizzle": "^0.2.3", 149 | "strip-json-comments": "^3.1.0", 150 | "taffydb": "2.6.2", 151 | "underscore": "~1.13.1" 152 | }, 153 | "bin": { 154 | "jsdoc": "jsdoc.js" 155 | }, 156 | "engines": { 157 | "node": ">=8.15.0" 158 | } 159 | }, 160 | "node_modules/klaw": { 161 | "version": "3.0.0", 162 | "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", 163 | "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", 164 | "dev": true, 165 | "dependencies": { 166 | "graceful-fs": "^4.1.9" 167 | } 168 | }, 169 | "node_modules/linkify-it": { 170 | "version": "2.2.0", 171 | "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", 172 | "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", 173 | "dev": true, 174 | "dependencies": { 175 | "uc.micro": "^1.0.1" 176 | } 177 | }, 178 | "node_modules/lodash": { 179 | "version": "4.17.21", 180 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", 181 | "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", 182 | "dev": true 183 | }, 184 | "node_modules/markdown-it": { 185 | "version": "10.0.0", 186 | "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz", 187 | "integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==", 188 | "dev": true, 189 | "dependencies": { 190 | "argparse": "^1.0.7", 191 | "entities": "~2.0.0", 192 | "linkify-it": "^2.0.0", 193 | "mdurl": "^1.0.1", 194 | "uc.micro": "^1.0.5" 195 | }, 196 | "bin": { 197 | "markdown-it": "bin/markdown-it.js" 198 | } 199 | }, 200 | "node_modules/markdown-it-anchor": { 201 | "version": "5.3.0", 202 | "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.3.0.tgz", 203 | "integrity": "sha512-/V1MnLL/rgJ3jkMWo84UR+K+jF1cxNG1a+KwqeXqTIJ+jtA8aWSHuigx8lTzauiIjBDbwF3NcWQMotd0Dm39jA==", 204 | "dev": true, 205 | "peerDependencies": { 206 | "markdown-it": "*" 207 | } 208 | }, 209 | "node_modules/marked": { 210 | "version": "2.1.3", 211 | "resolved": "https://registry.npmjs.org/marked/-/marked-2.1.3.tgz", 212 | "integrity": "sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==", 213 | "dev": true, 214 | "bin": { 215 | "marked": "bin/marked" 216 | }, 217 | "engines": { 218 | "node": ">= 10" 219 | } 220 | }, 221 | "node_modules/mdurl": { 222 | "version": "1.0.1", 223 | "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", 224 | "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", 225 | "dev": true 226 | }, 227 | "node_modules/mkdirp": { 228 | "version": "1.0.4", 229 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", 230 | "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", 231 | "dev": true, 232 | "bin": { 233 | "mkdirp": "bin/cmd.js" 234 | }, 235 | "engines": { 236 | "node": ">=10" 237 | } 238 | }, 239 | "node_modules/node-addon-api": { 240 | "version": "1.7.2", 241 | "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", 242 | "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==" 243 | }, 244 | "node_modules/requizzle": { 245 | "version": "0.2.3", 246 | "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", 247 | "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==", 248 | "dev": true, 249 | "dependencies": { 250 | "lodash": "^4.17.14" 251 | } 252 | }, 253 | "node_modules/sprintf-js": { 254 | "version": "1.0.3", 255 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 256 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 257 | "dev": true 258 | }, 259 | "node_modules/strip-json-comments": { 260 | "version": "3.1.1", 261 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", 262 | "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", 263 | "dev": true, 264 | "engines": { 265 | "node": ">=8" 266 | }, 267 | "funding": { 268 | "url": "https://github.com/sponsors/sindresorhus" 269 | } 270 | }, 271 | "node_modules/taffydb": { 272 | "version": "2.6.2", 273 | "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", 274 | "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", 275 | "dev": true 276 | }, 277 | "node_modules/typescript": { 278 | "version": "4.4.2", 279 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", 280 | "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==", 281 | "dev": true, 282 | "bin": { 283 | "tsc": "bin/tsc", 284 | "tsserver": "bin/tsserver" 285 | }, 286 | "engines": { 287 | "node": ">=4.2.0" 288 | } 289 | }, 290 | "node_modules/uc.micro": { 291 | "version": "1.0.6", 292 | "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", 293 | "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", 294 | "dev": true 295 | }, 296 | "node_modules/underscore": { 297 | "version": "1.13.1", 298 | "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz", 299 | "integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==", 300 | "dev": true 301 | }, 302 | "node_modules/xmlcreate": { 303 | "version": "2.0.3", 304 | "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.3.tgz", 305 | "integrity": "sha512-HgS+X6zAztGa9zIK3Y3LXuJes33Lz9x+YyTxgrkIdabu2vqcGOWwdfCpf1hWLRrd553wd4QCDf6BBO6FfdsRiQ==", 306 | "dev": true 307 | } 308 | }, 309 | "dependencies": { 310 | "@babel/parser": { 311 | "version": "7.15.3", 312 | "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.15.3.tgz", 313 | "integrity": "sha512-O0L6v/HvqbdJawj0iBEfVQMc3/6WP+AeOsovsIgBFyJaG+W2w7eqvZB7puddATmWuARlm1SX7DwxJ/JJUnDpEA==", 314 | "dev": true 315 | }, 316 | "@types/node": { 317 | "version": "16.7.10", 318 | "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.10.tgz", 319 | "integrity": "sha512-S63Dlv4zIPb8x6MMTgDq5WWRJQe56iBEY0O3SOFA9JrRienkOVDXSXBjjJw6HTNQYSE2JI6GMCR6LVbIMHJVvA==", 320 | "dev": true 321 | }, 322 | "argparse": { 323 | "version": "1.0.10", 324 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", 325 | "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", 326 | "dev": true, 327 | "requires": { 328 | "sprintf-js": "~1.0.2" 329 | } 330 | }, 331 | "bindings": { 332 | "version": "1.5.0", 333 | "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", 334 | "integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==", 335 | "requires": { 336 | "file-uri-to-path": "1.0.0" 337 | } 338 | }, 339 | "bluebird": { 340 | "version": "3.7.2", 341 | "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.7.2.tgz", 342 | "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", 343 | "dev": true 344 | }, 345 | "cargo-cp-artifact": { 346 | "version": "0.1.4", 347 | "resolved": "https://registry.npmjs.org/cargo-cp-artifact/-/cargo-cp-artifact-0.1.4.tgz", 348 | "integrity": "sha512-34yUas8aUENHGdk6JhLkV4ol0GLtP78YgqpsRDmmnpADy9JoTg/DgKM3CRHAeozTRNhKoPaRFhV+BxoqkmoKUA==", 349 | "dev": true 350 | }, 351 | "catharsis": { 352 | "version": "0.9.0", 353 | "resolved": "https://registry.npmjs.org/catharsis/-/catharsis-0.9.0.tgz", 354 | "integrity": "sha512-prMTQVpcns/tzFgFVkVp6ak6RykZyWb3gu8ckUpd6YkTlacOd3DXGJjIpD4Q6zJirizvaiAjSSHlOsA+6sNh2A==", 355 | "dev": true, 356 | "requires": { 357 | "lodash": "^4.17.15" 358 | } 359 | }, 360 | "deasync": { 361 | "version": "0.1.21", 362 | "resolved": "https://registry.npmjs.org/deasync/-/deasync-0.1.21.tgz", 363 | "integrity": "sha512-kUmM8Y+PZpMpQ+B4AuOW9k2Pfx/mSupJtxOsLzmnHY2WqZUYRFccFn2RhzPAqt3Xb+sorK/badW2D4zNzqZz5w==", 364 | "requires": { 365 | "bindings": "^1.5.0", 366 | "node-addon-api": "^1.7.1" 367 | } 368 | }, 369 | "entities": { 370 | "version": "2.0.3", 371 | "resolved": "https://registry.npmjs.org/entities/-/entities-2.0.3.tgz", 372 | "integrity": "sha512-MyoZ0jgnLvB2X3Lg5HqpFmn1kybDiIfEQmKzTb5apr51Rb+T3KdmMiqa70T+bhGnyv7bQ6WMj2QMHpGMmlrUYQ==", 373 | "dev": true 374 | }, 375 | "escape-string-regexp": { 376 | "version": "2.0.0", 377 | "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", 378 | "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", 379 | "dev": true 380 | }, 381 | "file-uri-to-path": { 382 | "version": "1.0.0", 383 | "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", 384 | "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==" 385 | }, 386 | "graceful-fs": { 387 | "version": "4.2.8", 388 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.8.tgz", 389 | "integrity": "sha512-qkIilPUYcNhJpd33n0GBXTB1MMPp14TxEsEs0pTrsSVucApsYzW5V+Q8Qxhik6KU3evy+qkAAowTByymK0avdg==", 390 | "dev": true 391 | }, 392 | "js2xmlparser": { 393 | "version": "4.0.1", 394 | "resolved": "https://registry.npmjs.org/js2xmlparser/-/js2xmlparser-4.0.1.tgz", 395 | "integrity": "sha512-KrPTolcw6RocpYjdC7pL7v62e55q7qOMHvLX1UCLc5AAS8qeJ6nukarEJAF2KL2PZxlbGueEbINqZR2bDe/gUw==", 396 | "dev": true, 397 | "requires": { 398 | "xmlcreate": "^2.0.3" 399 | } 400 | }, 401 | "jsdoc": { 402 | "version": "3.6.7", 403 | "resolved": "https://registry.npmjs.org/jsdoc/-/jsdoc-3.6.7.tgz", 404 | "integrity": "sha512-sxKt7h0vzCd+3Y81Ey2qinupL6DpRSZJclS04ugHDNmRUXGzqicMJ6iwayhSA0S0DwwX30c5ozyUthr1QKF6uw==", 405 | "dev": true, 406 | "requires": { 407 | "@babel/parser": "^7.9.4", 408 | "bluebird": "^3.7.2", 409 | "catharsis": "^0.9.0", 410 | "escape-string-regexp": "^2.0.0", 411 | "js2xmlparser": "^4.0.1", 412 | "klaw": "^3.0.0", 413 | "markdown-it": "^10.0.0", 414 | "markdown-it-anchor": "^5.2.7", 415 | "marked": "^2.0.3", 416 | "mkdirp": "^1.0.4", 417 | "requizzle": "^0.2.3", 418 | "strip-json-comments": "^3.1.0", 419 | "taffydb": "2.6.2", 420 | "underscore": "~1.13.1" 421 | } 422 | }, 423 | "klaw": { 424 | "version": "3.0.0", 425 | "resolved": "https://registry.npmjs.org/klaw/-/klaw-3.0.0.tgz", 426 | "integrity": "sha512-0Fo5oir+O9jnXu5EefYbVK+mHMBeEVEy2cmctR1O1NECcCkPRreJKrS6Qt/j3KC2C148Dfo9i3pCmCMsdqGr0g==", 427 | "dev": true, 428 | "requires": { 429 | "graceful-fs": "^4.1.9" 430 | } 431 | }, 432 | "linkify-it": { 433 | "version": "2.2.0", 434 | "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", 435 | "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", 436 | "dev": true, 437 | "requires": { 438 | "uc.micro": "^1.0.1" 439 | } 440 | }, 441 | "lodash": { 442 | "version": "4.17.21", 443 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", 444 | "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", 445 | "dev": true 446 | }, 447 | "markdown-it": { 448 | "version": "10.0.0", 449 | "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-10.0.0.tgz", 450 | "integrity": "sha512-YWOP1j7UbDNz+TumYP1kpwnP0aEa711cJjrAQrzd0UXlbJfc5aAq0F/PZHjiioqDC1NKgvIMX+o+9Bk7yuM2dg==", 451 | "dev": true, 452 | "requires": { 453 | "argparse": "^1.0.7", 454 | "entities": "~2.0.0", 455 | "linkify-it": "^2.0.0", 456 | "mdurl": "^1.0.1", 457 | "uc.micro": "^1.0.5" 458 | } 459 | }, 460 | "markdown-it-anchor": { 461 | "version": "5.3.0", 462 | "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-5.3.0.tgz", 463 | "integrity": "sha512-/V1MnLL/rgJ3jkMWo84UR+K+jF1cxNG1a+KwqeXqTIJ+jtA8aWSHuigx8lTzauiIjBDbwF3NcWQMotd0Dm39jA==", 464 | "dev": true, 465 | "requires": {} 466 | }, 467 | "marked": { 468 | "version": "2.1.3", 469 | "resolved": "https://registry.npmjs.org/marked/-/marked-2.1.3.tgz", 470 | "integrity": "sha512-/Q+7MGzaETqifOMWYEA7HVMaZb4XbcRfaOzcSsHZEith83KGlvaSG33u0SKu89Mj5h+T8V2hM+8O45Qc5XTgwA==", 471 | "dev": true 472 | }, 473 | "mdurl": { 474 | "version": "1.0.1", 475 | "resolved": "https://registry.npmjs.org/mdurl/-/mdurl-1.0.1.tgz", 476 | "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", 477 | "dev": true 478 | }, 479 | "mkdirp": { 480 | "version": "1.0.4", 481 | "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", 482 | "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", 483 | "dev": true 484 | }, 485 | "node-addon-api": { 486 | "version": "1.7.2", 487 | "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-1.7.2.tgz", 488 | "integrity": "sha512-ibPK3iA+vaY1eEjESkQkM0BbCqFOaZMiXRTtdB0u7b4djtY6JnsjvPdUHVMg6xQt3B8fpTTWHI9A+ADjM9frzg==" 489 | }, 490 | "requizzle": { 491 | "version": "0.2.3", 492 | "resolved": "https://registry.npmjs.org/requizzle/-/requizzle-0.2.3.tgz", 493 | "integrity": "sha512-YanoyJjykPxGHii0fZP0uUPEXpvqfBDxWV7s6GKAiiOsiqhX6vHNyW3Qzdmqp/iq/ExbhaGbVrjB4ruEVSM4GQ==", 494 | "dev": true, 495 | "requires": { 496 | "lodash": "^4.17.14" 497 | } 498 | }, 499 | "sprintf-js": { 500 | "version": "1.0.3", 501 | "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", 502 | "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", 503 | "dev": true 504 | }, 505 | "strip-json-comments": { 506 | "version": "3.1.1", 507 | "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", 508 | "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", 509 | "dev": true 510 | }, 511 | "taffydb": { 512 | "version": "2.6.2", 513 | "resolved": "https://registry.npmjs.org/taffydb/-/taffydb-2.6.2.tgz", 514 | "integrity": "sha1-fLy2S1oUG2ou/CxdLGe04VCyomg=", 515 | "dev": true 516 | }, 517 | "typescript": { 518 | "version": "4.4.2", 519 | "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.4.2.tgz", 520 | "integrity": "sha512-gzP+t5W4hdy4c+68bfcv0t400HVJMMd2+H9B7gae1nQlBzCqvrXX+6GL/b3GAgyTH966pzrZ70/fRjwAtZksSQ==", 521 | "dev": true 522 | }, 523 | "uc.micro": { 524 | "version": "1.0.6", 525 | "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", 526 | "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", 527 | "dev": true 528 | }, 529 | "underscore": { 530 | "version": "1.13.1", 531 | "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.1.tgz", 532 | "integrity": "sha512-hzSoAVtJF+3ZtiFX0VgfFPHEDRm7Y/QPjGyNo4TVdnDTdft3tr8hEkD25a1jC+TjTuE7tkHGKkhwCgs9dgBB2g==", 533 | "dev": true 534 | }, 535 | "xmlcreate": { 536 | "version": "2.0.3", 537 | "resolved": "https://registry.npmjs.org/xmlcreate/-/xmlcreate-2.0.3.tgz", 538 | "integrity": "sha512-HgS+X6zAztGa9zIK3Y3LXuJes33Lz9x+YyTxgrkIdabu2vqcGOWwdfCpf1hWLRrd553wd4QCDf6BBO6FfdsRiQ==", 539 | "dev": true 540 | } 541 | } 542 | } 543 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tikv-client", 3 | "version": "0.0.0", 4 | "description": "A TiKV client in Node.js.", 5 | "main": "index.js", 6 | "scripts": { 7 | "build": "cargo-cp-artifact -nc index.node -- cargo build --message-format=json-render-diagnostics & tsc", 8 | "install": "npm run build", 9 | "docs": "jsdoc ./dist", 10 | "demo": "node examples/raw_app.js", 11 | "clean": "rm -rf ./out & rm -rf ./dist" 12 | }, 13 | "author": "Mossaka", 14 | "license": "Apache-2.0", 15 | "devDependencies": { 16 | "@types/node": "^16.7.10", 17 | "cargo-cp-artifact": "^0.1", 18 | "jsdoc": "^3.6.7", 19 | "typescript": "^4.4.2" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "git+https://github.com/tikv/client-node.git" 24 | }, 25 | "bugs": { 26 | "url": "https://github.com/tikv/client-node/issues" 27 | }, 28 | "homepage": "https://github.com/tikv/client-node#readme", 29 | "dependencies": { 30 | "deasync": "^0.1.21" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /rust-toolchain: -------------------------------------------------------------------------------- 1 | 1.55 2 | -------------------------------------------------------------------------------- /src/error.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. 2 | 3 | use neon::prelude::*; 4 | use once_cell::sync::OnceCell; 5 | 6 | // Globally store a static reference to the `TRANSACTION_ERROR` class 7 | pub struct ClientErrors { 8 | pub operation_after_commit_error: OnceCell>, 9 | pub undetermined_error: OnceCell>, 10 | pub write_conlict_error: OnceCell>, 11 | pub already_exist_error: OnceCell>, 12 | pub daedlock_error: OnceCell>, 13 | } 14 | 15 | pub static CLIENT_ERRORS: ClientErrors = ClientErrors { 16 | operation_after_commit_error: OnceCell::new(), 17 | undetermined_error: OnceCell::new(), 18 | write_conlict_error: OnceCell::new(), 19 | already_exist_error: OnceCell::new(), 20 | daedlock_error: OnceCell::new(), 21 | }; 22 | 23 | pub trait CustomError { 24 | fn throw<'a, C>(&self, cx: &mut C, args: Vec) -> JsResult<'a, JsObject> 25 | where 26 | C: Context<'a>; 27 | } 28 | 29 | impl CustomError for OnceCell> { 30 | fn throw<'a, C>(&self, cx: &mut C, args: Vec) -> JsResult<'a, JsObject> 31 | where 32 | C: Context<'a>, 33 | { 34 | let args: Vec> = args.into_iter().map(|s| cx.string(s).upcast()).collect(); 35 | 36 | let error = self 37 | .get() 38 | .expect("Expected module to be initialized") 39 | .to_inner(cx); 40 | 41 | // Use `.construct` to call this as a constructor instead of a normal function 42 | error.construct(cx, args) 43 | } 44 | } 45 | 46 | pub fn init(mut cx: FunctionContext) -> JsResult { 47 | CLIENT_ERRORS 48 | .operation_after_commit_error 49 | .get_or_try_init(|| Ok(cx.argument::(0)?.root(&mut cx)))?; 50 | CLIENT_ERRORS 51 | .undetermined_error 52 | .get_or_try_init(|| Ok(cx.argument::(1)?.root(&mut cx)))?; 53 | CLIENT_ERRORS 54 | .write_conlict_error 55 | .get_or_try_init(|| Ok(cx.argument::(2)?.root(&mut cx)))?; 56 | CLIENT_ERRORS 57 | .already_exist_error 58 | .get_or_try_init(|| Ok(cx.argument::(3)?.root(&mut cx)))?; 59 | CLIENT_ERRORS 60 | .daedlock_error 61 | .get_or_try_init(|| Ok(cx.argument::(4)?.root(&mut cx)))?; 62 | Ok(cx.undefined()) 63 | } 64 | -------------------------------------------------------------------------------- /src/lib.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. 2 | 3 | use std::sync::Arc; 4 | 5 | use error::init; 6 | use neon::prelude::*; 7 | use tokio::sync::Mutex; 8 | 9 | mod error; 10 | mod raw; 11 | mod transaction; 12 | mod utils; 13 | 14 | pub struct RawClient { 15 | inner: Arc, 16 | } 17 | 18 | impl Finalize for RawClient {} 19 | 20 | pub struct TransactionClient { 21 | inner: Arc, 22 | } 23 | 24 | impl Finalize for TransactionClient {} 25 | 26 | pub struct Transaction { 27 | inner: Arc>, 28 | } 29 | 30 | impl Finalize for Transaction {} 31 | 32 | pub struct Snapshot { 33 | inner: Arc>, 34 | } 35 | 36 | impl Finalize for Snapshot {} 37 | 38 | #[neon::main] 39 | fn main(mut cx: ModuleContext) -> NeonResult<()> { 40 | cx.export_function("raw_connect", RawClient::connect)?; 41 | cx.export_function("raw_put", RawClient::put)?; 42 | cx.export_function("raw_get", RawClient::get)?; 43 | cx.export_function("raw_delete", RawClient::delete)?; 44 | cx.export_function("raw_batch_get", RawClient::batch_get)?; 45 | cx.export_function("raw_scan", RawClient::scan)?; 46 | cx.export_function("raw_scan_keys", RawClient::scan_keys)?; 47 | cx.export_function("raw_batch_put", RawClient::batch_put)?; 48 | cx.export_function("raw_batch_delete", RawClient::batch_delete)?; 49 | cx.export_function("raw_delete_range", RawClient::delete_range)?; 50 | 51 | cx.export_function("txn_connect", TransactionClient::connect)?; 52 | cx.export_function("txn_begin", TransactionClient::begin)?; 53 | cx.export_function("txn_snapshot", TransactionClient::snapshot)?; 54 | cx.export_function( 55 | "txn_current_timestamp", 56 | TransactionClient::current_timestamp, 57 | )?; 58 | cx.export_function("txn_gc", TransactionClient::gc)?; 59 | cx.export_function("txn_get", Transaction::get)?; 60 | cx.export_function("txn_get_for_update", Transaction::get_for_update)?; 61 | cx.export_function("txn_key_exists", Transaction::key_exists)?; 62 | cx.export_function("txn_batch_get", Transaction::batch_get)?; 63 | cx.export_function( 64 | "txn_batch_get_for_update", 65 | Transaction::batch_get_for_update, 66 | )?; 67 | cx.export_function("txn_scan", Transaction::scan)?; 68 | cx.export_function("txn_scan_keys", Transaction::scan_keys)?; 69 | cx.export_function("txn_lock_keys", Transaction::lock_keys)?; 70 | cx.export_function("txn_put", Transaction::put)?; 71 | cx.export_function("txn_insert", Transaction::insert)?; 72 | cx.export_function("txn_delete", Transaction::delete)?; 73 | cx.export_function("txn_commit", Transaction::commit)?; 74 | 75 | cx.export_function("snapshot_get", Snapshot::get)?; 76 | cx.export_function("snapshot_key_exists", Snapshot::key_exists)?; 77 | cx.export_function("snapshot_batch_get", Snapshot::batch_get)?; 78 | cx.export_function("snapshot_scan", Snapshot::scan)?; 79 | cx.export_function("snapshot_scan_keys", Snapshot::scan_keys)?; 80 | 81 | cx.export_function("init", init)?; 82 | Ok(()) 83 | } 84 | -------------------------------------------------------------------------------- /src/raw.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. 2 | 3 | use crate::{ 4 | utils::{js_array_to_rust_keys, js_array_to_rust_pairs, send_result, to_bound_range, RUNTIME}, 5 | RawClient, 6 | }; 7 | use neon::prelude::*; 8 | use std::{convert::TryInto, u32}; 9 | 10 | impl RawClient { 11 | pub fn connect(mut cx: FunctionContext) -> JsResult { 12 | let pd_endpoint = cx.argument::(0)?.value(&mut cx); 13 | let callback = cx.argument::(1)?.root(&mut cx); 14 | let result = tikv_client::RawClient::new(vec![pd_endpoint], None); 15 | let queue = cx.queue(); 16 | RUNTIME.spawn(async move { 17 | let result = result.await; 18 | send_result(queue, callback, result); 19 | }); 20 | Ok(cx.undefined()) 21 | } 22 | 23 | pub fn put(mut cx: FunctionContext) -> JsResult { 24 | let client = cx 25 | .this() 26 | .downcast_or_throw::, _>(&mut cx)?; 27 | let key = cx.argument::(0)?.value(&mut cx); 28 | let value = cx.argument::(1)?.value(&mut cx); 29 | let cf = cx.argument::(2)?.value(&mut cx); 30 | let callback = cx.argument::(3)?.root(&mut cx); 31 | 32 | let inner = client.inner.with_cf(cf.try_into().unwrap()); // TODO: #22 make CF optional 33 | let queue = cx.queue(); 34 | 35 | RUNTIME.spawn(async move { 36 | let result = inner.put(key, value).await; 37 | send_result(queue, callback, result); 38 | }); 39 | 40 | Ok(cx.undefined()) 41 | } 42 | 43 | pub fn get(mut cx: FunctionContext) -> JsResult { 44 | let client = cx 45 | .this() 46 | .downcast_or_throw::, _>(&mut cx)?; 47 | let key = cx.argument::(0)?.value(&mut cx); 48 | let cf = cx.argument::(1)?.value(&mut cx); 49 | let callback = cx.argument::(2)?.root(&mut cx); 50 | 51 | let inner = client.inner.with_cf(cf.try_into().unwrap()); 52 | let queue = cx.queue(); 53 | 54 | RUNTIME.spawn(async move { 55 | let value: Option> = inner.get(key).await.unwrap(); 56 | send_result(queue, callback, Ok(value)); 57 | }); 58 | 59 | Ok(cx.undefined()) 60 | } 61 | 62 | pub fn delete(mut cx: FunctionContext) -> JsResult { 63 | let client = cx 64 | .this() 65 | .downcast_or_throw::, _>(&mut cx)?; 66 | let key = cx.argument::(0)?.value(&mut cx); 67 | let cf = cx.argument::(1)?.value(&mut cx); 68 | let callback = cx.argument::(2)?.root(&mut cx); 69 | 70 | let inner = client.inner.with_cf(cf.try_into().unwrap()); 71 | let queue = cx.queue(); 72 | RUNTIME.spawn(async move { 73 | let result = inner.delete(key).await; 74 | send_result(queue, callback, result); 75 | }); 76 | 77 | Ok(cx.undefined()) 78 | } 79 | 80 | pub fn batch_get(mut cx: FunctionContext) -> JsResult { 81 | let client = cx 82 | .this() 83 | .downcast_or_throw::, _>(&mut cx)?; 84 | let keys = cx.argument::(0)?; 85 | let keys = js_array_to_rust_keys(&mut cx, keys); 86 | let cf = cx.argument::(1)?.value(&mut cx); 87 | let callback = cx.argument::(2)?.root(&mut cx); 88 | 89 | let inner = client.inner.with_cf(cf.try_into().unwrap()); 90 | let queue = cx.queue(); 91 | 92 | RUNTIME.spawn(async move { 93 | let result = inner.batch_get(keys).await; 94 | send_result(queue, callback, result); 95 | }); 96 | 97 | Ok(cx.undefined()) 98 | } 99 | 100 | pub fn scan(mut cx: FunctionContext) -> JsResult { 101 | let client = cx 102 | .this() 103 | .downcast_or_throw::, _>(&mut cx)?; 104 | let start = cx.argument::(0)?.value(&mut cx).into_bytes(); 105 | let end = cx.argument::(1)?.value(&mut cx).into_bytes(); 106 | let limit = cx.argument::(2)?.value(&mut cx) as u32; 107 | let include_start = cx.argument::(3)?.value(&mut cx); 108 | let include_end = cx.argument::(4)?.value(&mut cx); 109 | let cf = cx.argument::(5)?.value(&mut cx); 110 | 111 | let callback = cx.argument::(6)?.root(&mut cx); 112 | let inner = client.inner.with_cf(cf.try_into().unwrap()); 113 | let queue = cx.queue(); 114 | RUNTIME.spawn(async move { 115 | let range = to_bound_range(Some(start), Some(end), include_start, include_end); 116 | 117 | let result = inner.scan(range, limit).await; 118 | send_result(queue, callback, result); 119 | }); 120 | 121 | Ok(cx.undefined()) 122 | } 123 | 124 | pub fn scan_keys(mut cx: FunctionContext) -> JsResult { 125 | let client = cx 126 | .this() 127 | .downcast_or_throw::, _>(&mut cx)?; 128 | let start = cx.argument::(0)?.value(&mut cx).into_bytes(); 129 | let end = cx.argument::(1)?.value(&mut cx).into_bytes(); 130 | let limit = cx.argument::(2)?.value(&mut cx) as u32; 131 | let include_start = cx.argument::(3)?.value(&mut cx); 132 | let include_end = cx.argument::(4)?.value(&mut cx); 133 | let cf = cx.argument::(5)?.value(&mut cx); 134 | 135 | let callback = cx.argument::(6)?.root(&mut cx); 136 | let inner = client.inner.with_cf(cf.try_into().unwrap()); 137 | let queue = cx.queue(); 138 | RUNTIME.spawn(async move { 139 | let range = to_bound_range(Some(start), Some(end), include_start, include_end); 140 | 141 | let result = inner.scan_keys(range, limit).await; 142 | send_result(queue, callback, result); 143 | }); 144 | 145 | Ok(cx.undefined()) 146 | } 147 | 148 | pub fn batch_put(mut cx: FunctionContext) -> JsResult { 149 | let client = cx 150 | .this() 151 | .downcast_or_throw::, _>(&mut cx)?; 152 | let pairs = cx.argument::(0)?; 153 | let pairs = js_array_to_rust_pairs(&mut cx, pairs); 154 | let cf = cx.argument::(1)?.value(&mut cx); 155 | 156 | let callback = cx.argument::(2)?.root(&mut cx); 157 | let inner = client.inner.with_cf(cf.try_into().unwrap()); 158 | let queue = cx.queue(); 159 | RUNTIME.spawn(async move { 160 | let result = inner.batch_put(pairs).await; 161 | send_result(queue, callback, result); 162 | }); 163 | 164 | Ok(cx.undefined()) 165 | } 166 | 167 | pub fn batch_delete(mut cx: FunctionContext) -> JsResult { 168 | let client = cx 169 | .this() 170 | .downcast_or_throw::, _>(&mut cx)?; 171 | let keys = cx.argument::(0)?; 172 | let keys = js_array_to_rust_keys(&mut cx, keys); 173 | let cf = cx.argument::(1)?.value(&mut cx); 174 | 175 | let callback = cx.argument::(2)?.root(&mut cx); 176 | let inner = client.inner.with_cf(cf.try_into().unwrap()); 177 | let queue = cx.queue(); 178 | RUNTIME.spawn(async move { 179 | let result = inner.batch_delete(keys).await; 180 | send_result(queue, callback, result); 181 | }); 182 | 183 | Ok(cx.undefined()) 184 | } 185 | 186 | pub fn delete_range(mut cx: FunctionContext) -> JsResult { 187 | let client = cx 188 | .this() 189 | .downcast_or_throw::, _>(&mut cx)?; 190 | let queue = cx.queue(); 191 | let start = cx.argument::(0)?.value(&mut cx).into_bytes(); 192 | let end = cx.argument::(1)?.value(&mut cx).into_bytes(); 193 | let include_start = cx.argument::(2)?.value(&mut cx); 194 | let include_end = cx.argument::(3)?.value(&mut cx); 195 | let cf = cx.argument::(4)?.value(&mut cx); 196 | let inner = client.inner.with_cf(cf.try_into().unwrap()); 197 | 198 | let callback = cx.argument::(5)?.root(&mut cx); 199 | 200 | RUNTIME.spawn(async move { 201 | let range = to_bound_range(Some(start), Some(end), include_start, include_end); 202 | 203 | let result = inner.delete_range(range).await; 204 | send_result(queue, callback, result); 205 | }); 206 | 207 | Ok(cx.undefined()) 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /src/transaction.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. 2 | 3 | use crate::{ 4 | utils::{js_array_to_rust_keys, send_result, to_bound_range, RUNTIME}, 5 | Snapshot, Transaction, TransactionClient, 6 | }; 7 | use neon::prelude::*; 8 | use tikv_client::TimestampExt as _; 9 | use tikv_client::TransactionOptions; 10 | use tikv_client::{Key, KvPair}; 11 | 12 | impl TransactionClient { 13 | pub fn connect(mut cx: FunctionContext) -> JsResult { 14 | let pd_endpoint = cx.argument::(0)?.value(&mut cx); 15 | let callback = cx.argument::(1)?.root(&mut cx); 16 | let result = tikv_client::TransactionClient::new(vec![pd_endpoint], None); 17 | let queue = cx.queue(); 18 | RUNTIME.spawn(async move { 19 | let result = result.await; 20 | send_result(queue, callback, result); 21 | }); 22 | Ok(cx.undefined()) 23 | } 24 | 25 | pub fn begin(mut cx: FunctionContext) -> JsResult { 26 | let client = cx 27 | .this() 28 | .downcast_or_throw::, _>(&mut cx)?; 29 | let pessimistic = cx.argument::(0)?.value(&mut cx); 30 | let callback = cx.argument::(1)?.root(&mut cx); 31 | let inner = client.inner.clone(); 32 | 33 | let queue = cx.queue(); 34 | RUNTIME.spawn(async move { 35 | let inner = if pessimistic { 36 | inner.begin_pessimistic().await 37 | } else { 38 | inner.begin_optimistic().await 39 | }; 40 | send_result(queue, callback, inner); 41 | }); 42 | Ok(cx.undefined()) 43 | } 44 | 45 | pub fn snapshot(mut cx: FunctionContext) -> JsResult { 46 | let client = cx 47 | .this() 48 | .downcast_or_throw::, _>(&mut cx)?; 49 | let timestamp = cx.argument::(0)?.value(&mut cx) as u64; 50 | let pessimistic = cx.argument::(1)?.value(&mut cx); 51 | let callback = cx.argument::(2)?.root(&mut cx); 52 | let inner = client.inner.clone(); 53 | 54 | let queue = cx.queue(); 55 | RUNTIME.spawn(async move { 56 | let inner = inner.snapshot( 57 | tikv_client::Timestamp::from_version(timestamp), 58 | if pessimistic { 59 | TransactionOptions::new_pessimistic() 60 | } else { 61 | TransactionOptions::new_optimistic() 62 | }, 63 | ); 64 | send_result(queue, callback, Ok(inner)); 65 | }); 66 | Ok(cx.undefined()) 67 | } 68 | 69 | pub fn current_timestamp(mut cx: FunctionContext) -> JsResult { 70 | let client = cx 71 | .this() 72 | .downcast_or_throw::, _>(&mut cx)?; 73 | let callback = cx.argument::(0)?.root(&mut cx); 74 | let inner = client.inner.clone(); 75 | 76 | let queue = cx.queue(); 77 | RUNTIME.spawn(async move { 78 | let result = inner.current_timestamp().await; 79 | send_result(queue, callback, result.map(|op| Some(op))); 80 | }); 81 | Ok(cx.undefined()) 82 | } 83 | 84 | pub fn gc(mut cx: FunctionContext) -> JsResult { 85 | let client = cx 86 | .this() 87 | .downcast_or_throw::, _>(&mut cx)?; 88 | let safepoint = cx.argument::(0)?.value(&mut cx) as u64; 89 | let callback = cx.argument::(1)?.root(&mut cx); 90 | let inner = client.inner.clone(); 91 | 92 | let queue = cx.queue(); 93 | RUNTIME.spawn(async move { 94 | let result = inner 95 | .gc(tikv_client::Timestamp::from_version(safepoint)) 96 | .await; 97 | send_result(queue, callback, result); 98 | }); 99 | Ok(cx.undefined()) 100 | } 101 | } 102 | 103 | impl Snapshot { 104 | pub fn get(mut cx: FunctionContext) -> JsResult { 105 | let client = cx.this().downcast_or_throw::, _>(&mut cx)?; 106 | let key = cx.argument::(0)?.value(&mut cx); 107 | let callback = cx.argument::(1)?.root(&mut cx); 108 | 109 | let inner = client.inner.clone(); 110 | let queue = cx.queue(); 111 | 112 | RUNTIME.spawn(async move { 113 | let value = inner.lock().await.get(key).await; 114 | send_result(queue, callback, value); 115 | }); 116 | 117 | Ok(cx.undefined()) 118 | } 119 | 120 | pub fn key_exists(mut cx: FunctionContext) -> JsResult { 121 | let client = cx.this().downcast_or_throw::, _>(&mut cx)?; 122 | let key = cx.argument::(0)?.value(&mut cx); 123 | let callback = cx.argument::(1)?.root(&mut cx); 124 | 125 | let inner = client.inner.clone(); 126 | let queue = cx.queue(); 127 | 128 | RUNTIME.spawn(async move { 129 | let value = inner.lock().await.key_exists(key).await; 130 | send_result(queue, callback, value); 131 | }); 132 | 133 | Ok(cx.undefined()) 134 | } 135 | 136 | pub fn batch_get(mut cx: FunctionContext) -> JsResult { 137 | let client = cx.this().downcast_or_throw::, _>(&mut cx)?; 138 | let keys = cx.argument::(0)?; 139 | let keys: Vec = js_array_to_rust_keys(&mut cx, keys); 140 | let callback = cx.argument::(1)?.root(&mut cx); 141 | 142 | let inner = client.inner.clone(); 143 | let queue = cx.queue(); 144 | 145 | RUNTIME.spawn(async move { 146 | let result = inner 147 | .lock() 148 | .await 149 | .batch_get(keys) 150 | .await 151 | .map(|kvpairs| kvpairs.collect::>()); 152 | send_result(queue, callback, result); 153 | }); 154 | 155 | Ok(cx.undefined()) 156 | } 157 | 158 | pub fn scan(mut cx: FunctionContext) -> JsResult { 159 | let client = cx.this().downcast_or_throw::, _>(&mut cx)?; 160 | let start = cx.argument_opt(0).map(|start| { 161 | start 162 | .downcast::(&mut cx) 163 | .or_throw(&mut cx) 164 | .expect("Start should be a string") 165 | .value(&mut cx) 166 | .into_bytes() 167 | }); 168 | let end = cx.argument_opt(1).map(|end| { 169 | end.downcast::(&mut cx) 170 | .or_throw(&mut cx) 171 | .expect("End should be a string") 172 | .value(&mut cx) 173 | .into_bytes() 174 | }); 175 | let limit = cx.argument::(2)?.value(&mut cx) as u32; 176 | let include_start = cx.argument::(3)?.value(&mut cx); 177 | let include_end = cx.argument::(4)?.value(&mut cx); 178 | let callback = cx.argument::(5)?.root(&mut cx); 179 | 180 | let inner = client.inner.clone(); 181 | let queue = cx.queue(); 182 | RUNTIME.spawn(async move { 183 | let range = to_bound_range(start, end, include_start, include_end); 184 | 185 | let result = inner 186 | .lock() 187 | .await 188 | .scan(range, limit) 189 | .await 190 | .map(|kvpairs| kvpairs.collect::>()); 191 | send_result(queue, callback, result); 192 | }); 193 | 194 | Ok(cx.undefined()) 195 | } 196 | 197 | pub fn scan_keys(mut cx: FunctionContext) -> JsResult { 198 | let client = cx.this().downcast_or_throw::, _>(&mut cx)?; 199 | let start = cx.argument::(0)?.value(&mut cx).into_bytes(); 200 | let end = cx.argument::(1)?.value(&mut cx).into_bytes(); 201 | let limit = cx.argument::(2)?.value(&mut cx) as u32; 202 | let include_start = cx.argument::(3)?.value(&mut cx); 203 | let include_end = cx.argument::(4)?.value(&mut cx); 204 | let callback = cx.argument::(5)?.root(&mut cx); 205 | 206 | let inner = client.inner.clone(); 207 | let queue = cx.queue(); 208 | RUNTIME.spawn(async move { 209 | let range = to_bound_range(Some(start), Some(end), include_start, include_end); 210 | 211 | let result = inner 212 | .lock() 213 | .await 214 | .scan_keys(range, limit) 215 | .await 216 | .map(|kvpairs| kvpairs.collect::>()); 217 | send_result(queue, callback, result); 218 | }); 219 | 220 | Ok(cx.undefined()) 221 | } 222 | } 223 | 224 | impl Transaction { 225 | pub fn get(mut cx: FunctionContext) -> JsResult { 226 | let client = cx 227 | .this() 228 | .downcast_or_throw::, _>(&mut cx)?; 229 | let key = cx.argument::(0)?.value(&mut cx); 230 | let callback = cx.argument::(1)?.root(&mut cx); 231 | 232 | let inner = client.inner.clone(); 233 | let queue = cx.queue(); 234 | 235 | RUNTIME.spawn(async move { 236 | let value = inner.lock().await.get(key).await; 237 | send_result(queue, callback, value); 238 | }); 239 | 240 | Ok(cx.undefined()) 241 | } 242 | 243 | pub fn get_for_update(mut cx: FunctionContext) -> JsResult { 244 | let client = cx 245 | .this() 246 | .downcast_or_throw::, _>(&mut cx)?; 247 | let key = cx.argument::(0)?.value(&mut cx); 248 | let callback = cx.argument::(1)?.root(&mut cx); 249 | 250 | let inner = client.inner.clone(); 251 | let queue = cx.queue(); 252 | 253 | RUNTIME.spawn(async move { 254 | let value = inner.lock().await.get_for_update(key).await; 255 | send_result(queue, callback, value); 256 | }); 257 | 258 | Ok(cx.undefined()) 259 | } 260 | 261 | pub fn key_exists(mut cx: FunctionContext) -> JsResult { 262 | let client = cx 263 | .this() 264 | .downcast_or_throw::, _>(&mut cx)?; 265 | let key = cx.argument::(0)?.value(&mut cx); 266 | let callback = cx.argument::(1)?.root(&mut cx); 267 | 268 | let inner = client.inner.clone(); 269 | let queue = cx.queue(); 270 | 271 | RUNTIME.spawn(async move { 272 | let value = inner.lock().await.key_exists(key).await; 273 | send_result(queue, callback, value); 274 | }); 275 | 276 | Ok(cx.undefined()) 277 | } 278 | 279 | pub fn batch_get(mut cx: FunctionContext) -> JsResult { 280 | let client = cx 281 | .this() 282 | .downcast_or_throw::, _>(&mut cx)?; 283 | let keys = cx.argument::(0)?; 284 | let keys: Vec = js_array_to_rust_keys(&mut cx, keys); 285 | let callback = cx.argument::(1)?.root(&mut cx); 286 | 287 | let inner = client.inner.clone(); 288 | let queue = cx.queue(); 289 | 290 | RUNTIME.spawn(async move { 291 | let result = inner 292 | .lock() 293 | .await 294 | .batch_get(keys) 295 | .await 296 | .map(|kvpairs| kvpairs.collect::>()); 297 | send_result(queue, callback, result); 298 | }); 299 | 300 | Ok(cx.undefined()) 301 | } 302 | 303 | pub fn batch_get_for_update(mut cx: FunctionContext) -> JsResult { 304 | let client = cx 305 | .this() 306 | .downcast_or_throw::, _>(&mut cx)?; 307 | let keys = cx.argument::(0)?; 308 | let keys: Vec = js_array_to_rust_keys(&mut cx, keys); 309 | let callback = cx.argument::(1)?.root(&mut cx); 310 | 311 | let inner = client.inner.clone(); 312 | let queue = cx.queue(); 313 | 314 | RUNTIME.spawn(async move { 315 | let result = inner.lock().await.batch_get_for_update(keys).await; 316 | send_result(queue, callback, result); 317 | }); 318 | 319 | Ok(cx.undefined()) 320 | } 321 | 322 | pub fn scan(mut cx: FunctionContext) -> JsResult { 323 | let client = cx 324 | .this() 325 | .downcast_or_throw::, _>(&mut cx)?; 326 | let start = cx.argument::(0)?.value(&mut cx).into_bytes(); 327 | let end = cx.argument::(1)?.value(&mut cx).into_bytes(); 328 | let limit = cx.argument::(2)?.value(&mut cx) as u32; 329 | let include_start = cx.argument::(3)?.value(&mut cx); 330 | let include_end = cx.argument::(4)?.value(&mut cx); 331 | let callback = cx.argument::(5)?.root(&mut cx); 332 | 333 | let inner = client.inner.clone(); 334 | let queue = cx.queue(); 335 | RUNTIME.spawn(async move { 336 | let range = to_bound_range(Some(start), Some(end), include_start, include_end); 337 | 338 | let result = inner 339 | .lock() 340 | .await 341 | .scan(range, limit) 342 | .await 343 | .map(|kvpairs| kvpairs.collect::>()); 344 | send_result(queue, callback, result); 345 | }); 346 | 347 | Ok(cx.undefined()) 348 | } 349 | 350 | pub fn scan_keys(mut cx: FunctionContext) -> JsResult { 351 | let client = cx 352 | .this() 353 | .downcast_or_throw::, _>(&mut cx)?; 354 | let start = cx.argument::(0)?.value(&mut cx).into_bytes(); 355 | let end = cx.argument::(1)?.value(&mut cx).into_bytes(); 356 | let limit = cx.argument::(2)?.value(&mut cx) as u32; 357 | let include_start = cx.argument::(3)?.value(&mut cx); 358 | let include_end = cx.argument::(4)?.value(&mut cx); 359 | let callback = cx.argument::(5)?.root(&mut cx); 360 | 361 | let inner = client.inner.clone(); 362 | let queue = cx.queue(); 363 | RUNTIME.spawn(async move { 364 | let range = to_bound_range(Some(start), Some(end), include_start, include_end); 365 | 366 | let result = inner 367 | .lock() 368 | .await 369 | .scan_keys(range, limit) 370 | .await 371 | .map(|kvpairs| kvpairs.collect::>()); 372 | send_result(queue, callback, result); 373 | }); 374 | 375 | Ok(cx.undefined()) 376 | } 377 | 378 | pub fn lock_keys(mut cx: FunctionContext) -> JsResult { 379 | let client = cx 380 | .this() 381 | .downcast_or_throw::, _>(&mut cx)?; 382 | let keys = cx.argument::(0)?; 383 | let keys: Vec = js_array_to_rust_keys(&mut cx, keys); 384 | let callback = cx.argument::(1)?.root(&mut cx); 385 | 386 | let inner = client.inner.clone(); 387 | let queue = cx.queue(); 388 | 389 | RUNTIME.spawn(async move { 390 | let result = inner.lock().await.lock_keys(keys).await; 391 | send_result(queue, callback, result); 392 | }); 393 | 394 | Ok(cx.undefined()) 395 | } 396 | 397 | pub fn put(mut cx: FunctionContext) -> JsResult { 398 | let client = cx 399 | .this() 400 | .downcast_or_throw::, _>(&mut cx)?; 401 | let key = cx.argument::(0)?.value(&mut cx); 402 | let value = cx.argument::(1)?.value(&mut cx); 403 | let callback = cx.argument::(2)?.root(&mut cx); 404 | let inner = client.inner.clone(); 405 | let queue = cx.queue(); 406 | 407 | RUNTIME.spawn(async move { 408 | let result = inner.lock().await.put(key, value).await; 409 | send_result(queue, callback, result); 410 | }); 411 | 412 | Ok(cx.undefined()) 413 | } 414 | 415 | pub fn insert(mut cx: FunctionContext) -> JsResult { 416 | let client = cx 417 | .this() 418 | .downcast_or_throw::, _>(&mut cx)?; 419 | let key = cx.argument::(0)?.value(&mut cx); 420 | let value = cx.argument::(1)?.value(&mut cx); 421 | let callback = cx.argument::(2)?.root(&mut cx); 422 | let inner = client.inner.clone(); 423 | let queue = cx.queue(); 424 | 425 | RUNTIME.spawn(async move { 426 | let result = inner.lock().await.insert(key, value).await; 427 | send_result(queue, callback, result); 428 | }); 429 | 430 | Ok(cx.undefined()) 431 | } 432 | 433 | pub fn delete(mut cx: FunctionContext) -> JsResult { 434 | let client = cx 435 | .this() 436 | .downcast_or_throw::, _>(&mut cx)?; 437 | let key = cx.argument::(0)?.value(&mut cx); 438 | let callback = cx.argument::(1)?.root(&mut cx); 439 | let inner = client.inner.clone(); 440 | let queue = cx.queue(); 441 | 442 | RUNTIME.spawn(async move { 443 | let result = inner.lock().await.delete(key).await; 444 | send_result(queue, callback, result); 445 | }); 446 | 447 | Ok(cx.undefined()) 448 | } 449 | 450 | pub fn commit(mut cx: FunctionContext) -> JsResult { 451 | let client = cx 452 | .this() 453 | .downcast_or_throw::, _>(&mut cx)?; 454 | let callback = cx.argument::(0)?.root(&mut cx); 455 | let inner = client.inner.clone(); 456 | let queue = cx.queue(); 457 | 458 | RUNTIME.spawn(async move { 459 | let result = inner.lock().await.commit().await; 460 | send_result(queue, callback, result); 461 | }); 462 | 463 | Ok(cx.undefined()) 464 | } 465 | } 466 | -------------------------------------------------------------------------------- /src/utils.rs: -------------------------------------------------------------------------------- 1 | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. 2 | 3 | use std::ops::Bound; 4 | use std::{sync::Arc, u32}; 5 | 6 | use neon::prelude::*; 7 | use neon::{ 8 | context::{Context, TaskContext}, 9 | prelude::Handle, 10 | result::JsResultExt, 11 | types::{JsArray, JsString, JsValue}, 12 | }; 13 | use tikv_client::{Key, KvPair}; 14 | 15 | use tikv_client::TimestampExt; 16 | 17 | use crate::{ 18 | error::CustomError, error::CLIENT_ERRORS, RawClient, Snapshot, Transaction, TransactionClient, 19 | }; 20 | use lazy_static::lazy_static; 21 | use tokio::{runtime::Runtime, sync::Mutex}; 22 | 23 | lazy_static! { 24 | pub(crate) static ref RUNTIME: Runtime = Runtime::new().unwrap(); 25 | } 26 | 27 | pub fn bytes_to_js_string<'a>(cx: &mut TaskContext<'a>, bytes: Vec) -> Handle<'a, JsValue> { 28 | let content = std::str::from_utf8(&bytes).unwrap().to_owned(); 29 | cx.string(content).upcast() 30 | } 31 | 32 | // pub fn bytes_to_js_string<'a>(cx: &mut TaskContext<'a>, bytes: Vec) -> Handle<'a, JsValue> { 33 | // let content = std::str::from_utf8(&bytes).unwrap().to_owned(); 34 | // cx.string(content).upcast() 35 | // } 36 | 37 | pub trait ToJS: 'static + Send { 38 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue>; 39 | } 40 | 41 | impl ToJS for () { 42 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 43 | cx.undefined().upcast() 44 | } 45 | } 46 | 47 | impl ToJS for Vec { 48 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 49 | rust_keys_to_js_array(cx, self).upcast() 50 | } 51 | } 52 | 53 | impl ToJS for Key { 54 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 55 | bytes_to_js_string(cx, self.into()) 56 | } 57 | } 58 | 59 | impl ToJS for tikv_client::Value { 60 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 61 | bytes_to_js_string(cx, self.into()) 62 | } 63 | } 64 | 65 | impl ToJS for Vec { 66 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 67 | rust_pairs_to_js_array(cx, self).upcast() 68 | } 69 | } 70 | 71 | impl ToJS for tikv_client::RawClient { 72 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 73 | cx.boxed(RawClient { 74 | inner: Arc::new(self), 75 | }) 76 | .upcast() 77 | } 78 | } 79 | 80 | impl ToJS for tikv_client::TransactionClient { 81 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 82 | cx.boxed(TransactionClient { 83 | inner: Arc::new(self), 84 | }) 85 | .upcast() 86 | } 87 | } 88 | 89 | impl ToJS for tikv_client::Transaction { 90 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 91 | cx.boxed(Transaction { 92 | inner: Arc::new(Mutex::new(self)), 93 | }) 94 | .upcast() 95 | } 96 | } 97 | 98 | impl ToJS for tikv_client::Snapshot { 99 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 100 | cx.boxed(Snapshot { 101 | inner: Arc::new(Mutex::new(self)), 102 | }) 103 | .upcast() 104 | } 105 | } 106 | 107 | impl ToJS for Option { 108 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 109 | match self { 110 | None => cx.undefined().upcast(), 111 | Some(t) => t.to_js_value(cx), 112 | } 113 | } 114 | } 115 | 116 | impl ToJS for tikv_client::Timestamp { 117 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 118 | cx.number(self.version() as f64).upcast() 119 | } 120 | } 121 | 122 | impl ToJS for bool { 123 | fn to_js_value<'a>(self, cx: &mut TaskContext<'a>) -> Handle<'a, JsValue> { 124 | cx.boolean(self).upcast() 125 | } 126 | } 127 | 128 | pub fn rust_pairs_to_js_array<'a>( 129 | cx: &mut TaskContext<'a>, 130 | values: Vec, 131 | ) -> Handle<'a, JsArray> { 132 | let js_array = JsArray::new(cx, values.len() as u32); 133 | for (i, obj) in values.iter().enumerate() { 134 | let pair = JsArray::new(cx, 2); 135 | let v1 = cx.string( 136 | std::str::from_utf8(&Vec::from(obj.0.clone())) 137 | .unwrap() 138 | .to_owned(), 139 | ); 140 | let v2 = cx.string(std::str::from_utf8(&obj.1).unwrap().to_owned()); 141 | pair.set(cx, 0, v1).unwrap(); 142 | pair.set(cx, 1, v2).unwrap(); 143 | js_array.set(cx, i as u32, pair).unwrap(); 144 | } 145 | js_array 146 | } 147 | 148 | pub fn rust_keys_to_js_array<'a>(cx: &mut TaskContext<'a>, keys: Vec) -> Handle<'a, JsArray> { 149 | let js_array = JsArray::new(cx, keys.len() as u32); 150 | for (i, obj) in keys.into_iter().enumerate() { 151 | let v1 = obj.to_js_value(cx); 152 | js_array.set(cx, i as u32, v1).unwrap(); 153 | } 154 | js_array 155 | } 156 | 157 | pub fn js_array_to_rust_keys<'a>( 158 | cx: &mut FunctionContext<'a>, 159 | array: Handle, 160 | ) -> Vec { 161 | let array = array.to_vec(cx).unwrap(); // TODO: #21 remove unwrap here 162 | array 163 | .into_iter() 164 | .map(|k| { 165 | k.downcast::(cx) 166 | .or_throw(cx) 167 | .unwrap() 168 | .value(cx) 169 | }) 170 | .collect::>() 171 | } 172 | 173 | pub fn js_array_to_rust_pairs<'a>( 174 | cx: &mut FunctionContext<'a>, 175 | array: Handle, 176 | ) -> impl IntoIterator> { 177 | let array = array.to_vec(cx).unwrap(); // TODO: #21 remove unwrap here 178 | let mut pairs = vec![]; 179 | for k in array.into_iter() { 180 | let pair_result = k.downcast::(cx).or_throw(cx); 181 | match pair_result { 182 | Ok(pair) => { 183 | let args: Vec = vec![0_u32, 1_u32] 184 | .into_iter() 185 | .map(|i| { 186 | pair.get(cx, i as u32) 187 | .unwrap() 188 | .downcast::(cx) 189 | .or_throw(cx) 190 | .unwrap() // TODO: #21 remove unwrap here 191 | .value(cx) 192 | }) 193 | .collect(); 194 | pairs.push(KvPair::new( 195 | args.get(0).unwrap().to_owned(), 196 | args.get(1).unwrap().to_owned(), 197 | )); 198 | } 199 | Err(err) => println!("{}", err.to_string()), 200 | } 201 | } 202 | pairs 203 | } 204 | 205 | pub fn to_bound_range( 206 | start: Option>, 207 | end: Option>, 208 | include_start: bool, 209 | include_end: bool, 210 | ) -> tikv_client::BoundRange { 211 | let start_bound = if let Some(start) = start { 212 | if include_start { 213 | Bound::Included(start) 214 | } else { 215 | Bound::Excluded(start) 216 | } 217 | } else { 218 | Bound::Unbounded 219 | }; 220 | let end_bound = if let Some(end) = end { 221 | if include_end { 222 | Bound::Included(end) 223 | } else { 224 | Bound::Excluded(end) 225 | } 226 | } else { 227 | Bound::Unbounded 228 | }; 229 | tikv_client::BoundRange::from((start_bound, end_bound)) 230 | } 231 | 232 | pub fn send_result( 233 | // TODO: #18 do I have to use static lifetime here? 234 | queue: EventQueue, 235 | callback: Root, 236 | result: Result, 237 | ) { 238 | queue.send(move |mut cx| { 239 | let result = result.map(|op| op.to_js_value(&mut cx)); 240 | let callback = callback.into_inner(&mut cx); 241 | let this = cx.undefined(); 242 | let args: Vec> = match result { 243 | Ok(values) => vec![cx.null().upcast(), values], 244 | Err(err) => match err { 245 | err @ tikv_client::Error::OperationAfterCommitError => vec![ 246 | CLIENT_ERRORS 247 | .operation_after_commit_error 248 | .throw(&mut cx, vec![err.to_string()]) 249 | .unwrap() 250 | .upcast(), 251 | cx.undefined().upcast(), 252 | ], 253 | tikv_client::Error::UndeterminedError(e) => vec![ 254 | CLIENT_ERRORS 255 | .undetermined_error 256 | .throw( 257 | &mut cx, 258 | vec![format!("UndeterminedError: {:?}", &e.to_string())], 259 | ) 260 | .unwrap() 261 | .upcast(), 262 | cx.undefined().upcast(), 263 | ], 264 | tikv_client::Error::KeyError(e) => { 265 | if let Some(conflict) = e.conflict { 266 | vec![ 267 | CLIENT_ERRORS 268 | .write_conlict_error 269 | .throw(&mut cx, vec![format!("WriteConlict: {:?}", conflict)]) 270 | .unwrap() 271 | .upcast(), 272 | cx.undefined().upcast(), 273 | ] 274 | } else if let Some(already_exist) = e.already_exist { 275 | vec![ 276 | CLIENT_ERRORS 277 | .already_exist_error 278 | .throw(&mut cx, vec![format!("AlreadyExist: {:?}", already_exist)]) 279 | .unwrap() 280 | .upcast(), 281 | cx.undefined().upcast(), 282 | ] 283 | } else if let Some(deadlock) = e.deadlock { 284 | vec![ 285 | CLIENT_ERRORS 286 | .daedlock_error 287 | .throw(&mut cx, vec![format!("Daedlock: {:?}", deadlock)]) 288 | .unwrap() 289 | .upcast(), 290 | cx.undefined().upcast(), 291 | ] 292 | } else { 293 | vec![ 294 | cx.error(format!("KeyError: {:?}", e)).unwrap().upcast(), 295 | cx.undefined().upcast(), 296 | ] 297 | } 298 | } 299 | _ => vec![ 300 | cx.error(err.to_string()).unwrap().upcast(), 301 | cx.undefined().upcast(), 302 | ], 303 | }, 304 | }; 305 | callback.call(&mut cx, this, args)?; 306 | Ok(()) 307 | }); 308 | } 309 | -------------------------------------------------------------------------------- /tikv_client/asynchronous/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. 2 | 3 | "use strict"; 4 | 5 | const { promisify } = require("util"); 6 | // @ts-ignore 7 | const inner = require("../../index.node"); 8 | const { 9 | OperationAfterCommitError, 10 | UndertminedError, 11 | WriteConflictError, 12 | AlreadyExistError, 13 | DeadlockError, 14 | } = require("../error"); 15 | inner.init( 16 | OperationAfterCommitError, 17 | UndertminedError, 18 | WriteConflictError, 19 | AlreadyExistError, 20 | DeadlockError 21 | ); 22 | 23 | const connect_async = promisify(inner.raw_connect); 24 | const get_async = promisify(inner.raw_get); 25 | const put_async = promisify(inner.raw_put); 26 | const delete_async = promisify(inner.raw_delete); 27 | const batch_get_async = promisify(inner.raw_batch_get); 28 | const batch_put_async = promisify(inner.raw_batch_put); 29 | const batch_delete_async = promisify(inner.raw_batch_delete); 30 | const delete_range_async = promisify(inner.raw_delete_range); 31 | const scan_async = promisify(inner.raw_scan); 32 | const scan_keys_async = promisify(inner.raw_scan_keys); 33 | 34 | const txn_connect_async = promisify(inner.txn_connect); 35 | const txn_begin_async = promisify(inner.txn_begin); 36 | const txn_snapshot_async = promisify(inner.txn_snapshot); 37 | const txn_current_timestamp_async = promisify(inner.txn_current_timestamp); 38 | const txn_gc_async = promisify(inner.txn_gc); 39 | const txn_get_async = promisify(inner.txn_get); 40 | const txn_get_for_update_async = promisify(inner.txn_get_for_update); 41 | const txn_key_exists_async = promisify(inner.txn_key_exists); 42 | const txn_batch_get_async = promisify(inner.txn_batch_get); 43 | const txn_batch_get_for_update_async = promisify( 44 | inner.txn_batch_get_for_update 45 | ); 46 | const txn_scan_async = promisify(inner.txn_scan); 47 | const txn_scan_keys_async = promisify(inner.txn_scan_keys); 48 | const txn_lock_keys_async = promisify(inner.txn_lock_keys); 49 | const txn_put_async = promisify(inner.txn_put); 50 | const txn_insert_async = promisify(inner.txn_insert); 51 | const txn_delete_async = promisify(inner.txn_delete); 52 | const txn_commit_async = promisify(inner.txn_commit); 53 | 54 | const snapshot_get_async = promisify(inner.snapshot_get); 55 | const snapshot_key_exists_async = promisify(inner.snapshot_key_exists); 56 | const snapshot_batch_get_async = promisify(inner.snapshot_batch_get); 57 | const snapshot_scan_async = promisify(inner.snapshot_scan); 58 | const snapshot_scan_keys_async = promisify(inner.snapshot_scan_keys); 59 | 60 | export class RawClient { 61 | boxed: any; 62 | constructor(pd_endpoint: string) { 63 | // @ts-ignore 64 | return (async () => { 65 | this.boxed = await connect_async(pd_endpoint); 66 | return this; 67 | })(); 68 | } 69 | 70 | get(key: string, cf: string) { 71 | return get_async.call(this.boxed, key, cf); 72 | } 73 | 74 | put(key: string, value: string, cf: string) { 75 | return put_async.call(this.boxed, key, value, cf); 76 | } 77 | 78 | delete(key: string, cf: string) { 79 | return delete_async.call(this.boxed, key, cf); 80 | } 81 | 82 | batch_get(keys: string[], cf: string) { 83 | return batch_get_async.call(this.boxed, keys, cf); 84 | } 85 | 86 | batch_put(kv_pairs: string[], cf: string) { 87 | return batch_put_async.call(this.boxed, kv_pairs, cf); 88 | } 89 | 90 | batch_delete(keys: any, cf: any) { 91 | return batch_delete_async.call(this.boxed, keys, cf); 92 | } 93 | 94 | scan( 95 | start: string, 96 | end: string, 97 | limit: number, 98 | include_start: boolean, 99 | include_end: boolean, 100 | cf: string 101 | ) { 102 | return scan_async.call( 103 | this.boxed, 104 | start, 105 | end, 106 | limit, 107 | include_start, 108 | include_end, 109 | cf 110 | ); 111 | } 112 | 113 | scan_keys( 114 | start: string, 115 | end: string, 116 | limit: number, 117 | include_start: boolean, 118 | include_end: boolean, 119 | cf: string 120 | ) { 121 | return scan_keys_async.call( 122 | this.boxed, 123 | start, 124 | end, 125 | limit, 126 | include_start, 127 | include_end, 128 | cf 129 | ); 130 | } 131 | 132 | delete_range( 133 | start: string, 134 | end: string, 135 | include_start: boolean, 136 | include_end: boolean, 137 | cf: string 138 | ) { 139 | return delete_range_async.call( 140 | this.boxed, 141 | start, 142 | end, 143 | include_start, 144 | include_end, 145 | cf 146 | ); 147 | } 148 | } 149 | 150 | export class Transaction { 151 | boxed: any; 152 | constructor(boxed: any) { 153 | this.boxed = boxed; 154 | } 155 | 156 | get(key: string) { 157 | return txn_get_async.call(this.boxed, key); 158 | } 159 | 160 | get_for_update(key: string) { 161 | return txn_get_for_update_async.call(this.boxed, key); 162 | } 163 | 164 | put(key: string, value: string) { 165 | return txn_put_async.call(this.boxed, key, value); 166 | } 167 | 168 | insert(key: string, value: string) { 169 | return txn_insert_async.call(this.boxed, key, value); 170 | } 171 | 172 | delete(key: string) { 173 | return txn_delete_async.call(this.boxed, key); 174 | } 175 | 176 | commit() { 177 | return txn_commit_async.call(this.boxed); 178 | } 179 | 180 | key_exists(key: string) { 181 | return txn_key_exists_async.call(this.boxed, key); 182 | } 183 | 184 | batch_get(keys: string[]) { 185 | return txn_batch_get_async.call(this.boxed, keys); 186 | } 187 | 188 | batch_get_for_update(keys: string[]) { 189 | return txn_batch_get_for_update_async.call(this.boxed, keys); 190 | } 191 | 192 | scan( 193 | start: string, 194 | end: string, 195 | limit: number, 196 | include_start: boolean, 197 | include_end: boolean 198 | ) { 199 | return txn_scan_async.call( 200 | this.boxed, 201 | start, 202 | end, 203 | limit, 204 | include_start, 205 | include_end 206 | ); 207 | } 208 | 209 | scan_keys( 210 | start: string, 211 | end: string, 212 | limit: number, 213 | include_start: boolean, 214 | include_end: boolean 215 | ) { 216 | return txn_scan_keys_async.call( 217 | this.boxed, 218 | start, 219 | end, 220 | limit, 221 | include_start, 222 | include_end 223 | ); 224 | } 225 | 226 | lock_keys(keys: string[]) { 227 | return txn_lock_keys_async.call(this.boxed, keys); 228 | } 229 | } 230 | 231 | export class Snapshot { 232 | boxed: any; 233 | constructor(boxed: any) { 234 | this.boxed = boxed; 235 | } 236 | 237 | get(key: string) { 238 | return snapshot_get_async.call(this.boxed, key); 239 | } 240 | key_exists(key: string) { 241 | return snapshot_key_exists_async.call(this.boxed, key); 242 | } 243 | batch_get(keys: string[]) { 244 | return snapshot_batch_get_async.call(this.boxed, keys); 245 | } 246 | scan( 247 | start: string, 248 | end: string, 249 | limit: number, 250 | include_start: boolean, 251 | include_end: boolean 252 | ) { 253 | return snapshot_scan_async.call( 254 | this.boxed, 255 | start, 256 | end, 257 | limit, 258 | include_start, 259 | include_end 260 | ); 261 | } 262 | scan_keys( 263 | start: string, 264 | end: string, 265 | limit: number, 266 | include_start: boolean, 267 | include_end: boolean 268 | ) { 269 | return snapshot_scan_keys_async.call( 270 | this.boxed, 271 | start, 272 | end, 273 | limit, 274 | include_start, 275 | include_end 276 | ); 277 | } 278 | } 279 | export class TransactionClient { 280 | boxed: any; 281 | constructor(pd_endpoint: string) { 282 | // @ts-ignore 283 | return (async () => { 284 | this.boxed = await txn_connect_async(pd_endpoint); 285 | return this; 286 | })(); 287 | } 288 | 289 | begin(pessimistic: boolean) { 290 | return (async () => { 291 | const boxed = await txn_begin_async.call(this.boxed, pessimistic); 292 | return new Transaction(boxed); 293 | })(); 294 | } 295 | 296 | snapshot(timestamp: number, pessimistic: boolean) { 297 | return (async () => { 298 | const boxed = await txn_snapshot_async.call( 299 | this.boxed, 300 | timestamp, 301 | pessimistic 302 | ); 303 | return new Snapshot(boxed); 304 | })(); 305 | } 306 | 307 | current_timestamp() { 308 | return txn_current_timestamp_async.call(this.boxed); 309 | } 310 | 311 | gc(safepoint: number) { 312 | return txn_gc_async.call(this.boxed, safepoint); 313 | } 314 | } 315 | -------------------------------------------------------------------------------- /tikv_client/error.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. 2 | 3 | "use strict"; 4 | 5 | export class OperationAfterCommitError extends Error { 6 | /** 7 | * @class OperationAfterCommitError 8 | * @param { string } message - the error message 9 | */ 10 | constructor(message: string) { 11 | super(message); 12 | } 13 | } 14 | 15 | export class UndertminedError extends Error { 16 | /** 17 | * @class UndertminedError 18 | * @param { string } message - the error message 19 | */ 20 | constructor(message: string) { 21 | super(message); 22 | } 23 | } 24 | 25 | export class WriteConflictError extends Error { 26 | /** 27 | * @class WriteConflictError 28 | * @param { string } message - the error message 29 | */ 30 | constructor(message: string) { 31 | super(message); 32 | } 33 | } 34 | 35 | export class AlreadyExistError extends Error { 36 | /** 37 | * @class AlreadyExistError 38 | * @param { string } message - the error message 39 | */ 40 | constructor(message: string) { 41 | super(message); 42 | } 43 | } 44 | 45 | export class DeadlockError extends Error { 46 | /** 47 | * @class DeadlockError 48 | * @param { string } message - the error message 49 | */ 50 | constructor(message: string) { 51 | super(message); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /tikv_client/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2021 TiKV Project Authors. Licensed under Apache-2.0. 2 | 3 | "use strict"; 4 | 5 | // @ts-ignore 6 | const inner = require("../index.node"); 7 | import { OperationAfterCommitError, UndertminedError, WriteConflictError, AlreadyExistError, DeadlockError } from "./error"; 8 | inner.init( 9 | OperationAfterCommitError, 10 | UndertminedError, 11 | WriteConflictError, 12 | AlreadyExistError, 13 | DeadlockError 14 | ); 15 | 16 | var deasync = require("deasync"); 17 | const raw_connect_sync = deasync(inner.raw_connect); 18 | const get_sync = deasync(inner.raw_get); 19 | const put_sync = deasync(inner.raw_put); 20 | const delete_sync = deasync(inner.raw_delete); 21 | const batch_get_sync = deasync(inner.raw_batch_get); 22 | const batch_put_sync = deasync(inner.raw_batch_put); 23 | const batch_delete_sync = deasync(inner.raw_batch_delete); 24 | const delete_range_sync = deasync(inner.raw_delete_range); 25 | const scan_sync = deasync(inner.raw_scan); 26 | const scan_keys_sync = deasync(inner.raw_scan_keys); 27 | const txn_connect_sync = deasync(inner.txn_connect); 28 | const txn_begin_sync = deasync(inner.txn_begin); 29 | const txn_snapshot_sync = deasync(inner.txn_snapshot); 30 | const txn_current_timestamp_sync = deasync(inner.txn_current_timestamp); 31 | const txn_gc_sync = deasync(inner.txn_gc); 32 | const txn_get_sync = deasync(inner.txn_get); 33 | const txn_get_for_update_sync = deasync(inner.txn_get_for_update); 34 | const txn_key_exists_sync = deasync(inner.txn_key_exists); 35 | const txn_batch_get_sync = deasync(inner.txn_batch_get); 36 | const txn_batch_get_for_update_sync = deasync(inner.txn_batch_get_for_update); 37 | const txn_scan_sync = deasync(inner.txn_scan); 38 | const txn_scan_keys_sync = deasync(inner.txn_scan_keys); 39 | const txn_lock_keys_sync = deasync(inner.txn_lock_keys); 40 | const txn_put_sync = deasync(inner.txn_put); 41 | const txn_insert_sync = deasync(inner.txn_insert); 42 | const txn_delete_sync = deasync(inner.txn_delete); 43 | const txn_commit_sync = deasync(inner.txn_commit); 44 | const snapshot_get_sync = deasync(inner.snapshot_get); 45 | const snapshot_key_exists_sync = deasync(inner.snapshot_key_exists); 46 | const snapshot_batch_get_sync = deasync(inner.snapshot_batch_get); 47 | const snapshot_scan_sync = deasync(inner.snapshot_scan); 48 | const snapshot_scan_keys_sync = deasync(inner.snapshot_scan_keys); 49 | 50 | export class RawClient { 51 | boxed: any; 52 | /** 53 | * Construct a raw client. 54 | * @class RawClient 55 | * @param { string } pd_endpoint - PD endpoint 56 | * @example new tikv.RawClient("127.0.0.1:2379") 57 | */ 58 | constructor(pd_endpoint: string) { 59 | this.boxed = raw_connect_sync(pd_endpoint); 60 | } 61 | 62 | /** 63 | * Get a raw key. 64 | * @param { string } key - raw key 65 | * @param { string } cf - configuration 66 | * @example client.get("key", "default") 67 | */ 68 | get(key: string, cf: string) { 69 | return get_sync.call(this.boxed, key, cf); 70 | } 71 | 72 | /** 73 | * Put a raw key. 74 | * @param { string } key - raw key 75 | * @param { string } value - raw value 76 | * @param { string } cf - configuration 77 | * @example client.put("key", "value", "default") 78 | */ 79 | put(key: string, value: string, cf: string) { 80 | return put_sync.call(this.boxed, key, value, cf); 81 | } 82 | 83 | /** 84 | * Delete a raw key. 85 | * @param { string } key - raw key 86 | * @param { string } cf - configuration 87 | * @example client.delete("key", "default") 88 | * @returns { boolean } 89 | */ 90 | delete(key: string, cf: string): boolean { 91 | return delete_sync.call(this.boxed, key, cf); 92 | } 93 | 94 | /** 95 | * Batch get raw keys. 96 | * @param { string[] } keys - raw keys 97 | * @param { string } cf - configuration 98 | * @example client.batch_get(["key1", "key2"], "default") 99 | */ 100 | batch_get(keys: string[], cf: string) { 101 | return batch_get_sync.call(this.boxed, keys, cf); 102 | } 103 | 104 | /** 105 | * Batch put raw keys. 106 | * @param { string[] } keys - raw keys 107 | * @param { string[] } values - raw values 108 | * @param { string } cf - configuration 109 | * @example client.batch_put(["key1", "key2"], ["value1", "value2"], "default") 110 | */ 111 | batch_put(keys: string[], cf: string) { 112 | return batch_put_sync.call(this.boxed, keys, cf); 113 | } 114 | 115 | /** 116 | * Batch delete raw keys. 117 | * @param { string[] } keys - raw keys 118 | * @param { string } cf - configuration 119 | * @example client.batch_delete(["key1", "key2"], "default") 120 | */ 121 | batch_delete(keys: string[], cf: string) { 122 | return batch_delete_sync.call(this.boxed, keys, cf); 123 | } 124 | 125 | /** 126 | * Create a new 'scan' request. 127 | * @param { string } start - start key 128 | * @param { string } end - end key 129 | * @param { number } limit - limit 130 | * @param { boolean } include_start - include start key 131 | * @param { boolean } include_end - include end key 132 | * @param { string } cf - configuration 133 | * @example client.scan("k1", "k5", 10, true, true, "default"); 134 | */ 135 | scan(start: string, end: string, limit: number, include_start: boolean, include_end: boolean, cf: string) { 136 | return scan_sync.call( 137 | this.boxed, 138 | start, 139 | end, 140 | limit, 141 | include_start, 142 | include_end, 143 | cf 144 | ); 145 | } 146 | 147 | /** 148 | * Create a new 'scan_keys' request. 149 | * @param { string } start - start key 150 | * @param { string } end - end key 151 | * @param { number } limit - limit 152 | * @param { boolean } include_start - include start key 153 | * @param { boolean } include_end - include end key 154 | * @param { string } cf - configuration 155 | * @example client.scan_keys("k1", "k5", 10, true, true, "default"); 156 | */ 157 | scan_keys(start: string, end: string, limit: number, include_start: boolean, include_end: boolean, cf: string) { 158 | return scan_keys_sync.call( 159 | this.boxed, 160 | start, 161 | end, 162 | limit, 163 | include_start, 164 | include_end, 165 | cf 166 | ); 167 | } 168 | 169 | /** 170 | * Create a new 'delete_range' request. 171 | * @param { string } start - start key 172 | * @param { string } end - end key 173 | * @param { boolean } include_start - include start key 174 | * @param { boolean } include_end - include end key 175 | * @param { string } cf - configuration 176 | * @example client.delete_range("k1", "k5", true, true, "default"); 177 | */ 178 | delete_range(start: string, end: string, include_start: boolean, include_end: boolean, cf: string) { 179 | return delete_range_sync.call( 180 | this.boxed, 181 | start, 182 | end, 183 | include_start, 184 | include_end, 185 | cf 186 | ); 187 | } 188 | } 189 | 190 | export class Transaction { 191 | boxed: any; 192 | /** 193 | * @class Transaction 194 | * @example 195 | * const client = new tikv.RawClient("127.0.0.1:2379"); 196 | * const txn = client.begin(); 197 | */ 198 | constructor(boxed: any) { 199 | this.boxed = boxed; 200 | } 201 | 202 | /** 203 | * Create a new 'get' request. 204 | * @param { string } key - key 205 | * @example 206 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 207 | * const txn = client.begin(true); 208 | * txn.get("key") 209 | */ 210 | get(key: string) { 211 | return txn_get_sync.call(this.boxed, key); 212 | } 213 | 214 | /** 215 | * Create a `get for update` request. 216 | * @param { string } key - key 217 | * @example 218 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 219 | * const txn = client.begin(true); 220 | * txn.get_for_update("key") 221 | * txn.commit() 222 | */ 223 | get_for_update(key: string) { 224 | return txn_get_for_update_sync.call(this.boxed, key); 225 | } 226 | 227 | /** 228 | * Create a new 'put' request. 229 | * @param { string } key - key 230 | * @param { string } value - value 231 | * @example 232 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 233 | * const txn = client.begin(true); 234 | * txn.put("key", "value") 235 | * txn.commit() 236 | */ 237 | put(key: string, value: string) { 238 | return txn_put_sync.call(this.boxed, key, value); 239 | } 240 | 241 | /** 242 | * Create a new 'insert' request. 243 | * @param { string } key - key 244 | * @param { string } value - value 245 | * @example 246 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 247 | * const txn = client.begin(true); 248 | * txn.insert("key", "value") 249 | * txn.commit() 250 | */ 251 | insert(key: string, value: string) { 252 | return txn_insert_sync.call(this.boxed, key, value); 253 | } 254 | 255 | /** 256 | * Create a new 'delete' request. 257 | * @param { string } key - key 258 | * @example 259 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 260 | * const txn = client.begin(true); 261 | * txn.delete("key") 262 | * txn.commit() 263 | */ 264 | delete(key: string) { 265 | return txn_delete_sync.call(this.boxed, key); 266 | } 267 | 268 | /** 269 | * Create a new 'commit' request. 270 | * @example 271 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 272 | * const txn = client.begin(true); 273 | * //... Do some actions. 274 | * txn.commit() 275 | */ 276 | commit() { 277 | return txn_commit_sync.call(this.boxed); 278 | } 279 | 280 | /** 281 | * Check whether a key exists. 282 | * @param { string } key - key 283 | * @example 284 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 285 | * const txn = client.begin(true); 286 | * txn.exists("key") 287 | * txn.commit() 288 | */ 289 | key_exists(key: string) { 290 | return txn_key_exists_sync.call(this.boxed, key); 291 | } 292 | 293 | /** 294 | * Create a new 'batch get' request. 295 | * @param { string[] } keys - keys 296 | * @example 297 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 298 | * const txn = client.begin(true); 299 | * txn.batch_get(["key1", "key2"]) 300 | * txn.commit() 301 | * //=> [{key: "key1", value: "value1"}, {key: "key2", value: "value2"}] 302 | */ 303 | batch_get(keys: string[]) { 304 | return txn_batch_get_sync.call(this.boxed, keys); 305 | } 306 | 307 | /** 308 | * Create a new 'batch get for update' request. 309 | * @param { string[] } keys - keys 310 | * @example 311 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 312 | * const txn = client.begin(true); 313 | * txn.batch_get_for_update(["key1", "key2"]) 314 | * txn.commit() 315 | * //=> [{key: "key1", value: "value1"}, {key: "key2", value: "value2"}] 316 | */ 317 | batch_get_for_update(keys: string[]) { 318 | return txn_batch_get_for_update_sync.call(this.boxed, keys); 319 | } 320 | 321 | /** 322 | * Create a new 'scan' request. 323 | * @param { string } start - start key 324 | * @param { string } end - end key 325 | * @param { number } limit - limit 326 | * @param { boolean } include_start - include start key 327 | * @param { boolean } include_end - include end key 328 | * @example 329 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 330 | * const txn = client.begin(true); 331 | * txn.scan("start", "end", 10, true, true) 332 | * txn.commit() 333 | */ 334 | scan(start: string, end: string, limit: number, include_start: boolean, include_end: boolean) { 335 | return txn_scan_sync.call( 336 | this.boxed, 337 | start, 338 | end, 339 | limit, 340 | include_start, 341 | include_end 342 | ); 343 | } 344 | 345 | /** 346 | * Create a new 'scan keys' request. 347 | * @param { string } start - start key 348 | * @param { string } end - end key 349 | * @param { number } limit - limit 350 | * @param { boolean } include_start - include start key 351 | * @param { boolean } include_end - include end key 352 | * @example 353 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 354 | * const txn = client.begin(true); 355 | * txn.scan_keys("start", "end", 10, true, true) 356 | * txn.commit() 357 | * //=> ["key1", "key2"] 358 | */ 359 | scan_keys(start: string, end: string, limit: number, include_start: boolean, include_end: boolean) { 360 | return txn_scan_keys_sync.call( 361 | this.boxed, 362 | start, 363 | end, 364 | limit, 365 | include_start, 366 | include_end 367 | ); 368 | } 369 | 370 | /** 371 | * Create a new 'lock keys' request. 372 | * @param { string[] } keys - keys 373 | * @example 374 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 375 | * const txn = client.begin(true); 376 | * txn.lock_keys(["key1", "key2"]) 377 | * txn.commit() 378 | */ 379 | lock_keys(keys: string[]) { 380 | return txn_lock_keys_sync.call(this.boxed, keys); 381 | } 382 | } 383 | 384 | export class Snapshot { 385 | boxed: any; 386 | /** 387 | * @class Snapshot 388 | */ 389 | constructor(boxed: any) { 390 | this.boxed = boxed; 391 | } 392 | 393 | /** 394 | * Create a new 'get' request. 395 | * @param { string } key - key 396 | * @example 397 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 398 | * const snapshot = client.snapshot(client.current_timestamp(), true); 399 | * snapshot.get("key") 400 | * //=> {key: "key", value: "value"} 401 | */ 402 | get(key: string) { 403 | return snapshot_get_sync.call(this.boxed, key); 404 | } 405 | 406 | /** 407 | * Create a new 'key exists' request. 408 | * @param { string } key - key 409 | * @example 410 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 411 | * const snapshot = client.snapshot(client.current_timestamp(), true); 412 | * snapshot.key_exists("key") 413 | * //=> true 414 | */ 415 | key_exists(key: string) { 416 | return snapshot_key_exists_sync.call(this.boxed, key); 417 | } 418 | 419 | /** 420 | * Create a new 'batch get' request. 421 | * @param { string[] } keys - keys 422 | * @example 423 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 424 | * const snapshot = client.snapshot(client.current_timestamp(), true); 425 | * snapshot.batch_get(["key1", "key2"]) 426 | * //=> [{key: "key1", value: "value1"}, {key: "key2", value: "value2"}] 427 | */ 428 | batch_get(keys: any) { 429 | return snapshot_batch_get_sync.call(this.boxed, keys); 430 | } 431 | 432 | /** 433 | * Create a new 'scan' request. 434 | * @param { string } start - start key 435 | * @param { string } end - end key 436 | * @param { number } limit - limit 437 | * @param { boolean } include_start - include start key 438 | * @param { boolean } include_end - include end key 439 | * @example 440 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 441 | * const snapshot = client.snapshot(client.current_timestamp(), true); 442 | * snapshot.scan("start", "end", 10, true, true) 443 | * //=> [{key: "key1", value: "value1"}, {key: "key2", value: "value2"}] 444 | */ 445 | scan(start: string, end: string, limit: number, include_start: boolean, include_end: boolean) { 446 | return snapshot_scan_sync.call( 447 | this.boxed, 448 | start, 449 | end, 450 | limit, 451 | include_start, 452 | include_end 453 | ); 454 | } 455 | 456 | /** 457 | * Create a new 'scan keys' request. 458 | * @param { string } start - start key 459 | * @param { string } end - end key 460 | * @param { number } limit - limit 461 | * @param { boolean } include_start - include start key 462 | * @param { boolean } include_end - include end key 463 | * @example 464 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 465 | * const snapshot = client.snapshot(client.current_timestamp(), true); 466 | * snapshot.scan_keys("start", "end", 10, true, true) 467 | * //=> ["key1", "key2"] 468 | */ 469 | scan_keys(start: string, end: string, limit: number, include_start: boolean, include_end: boolean) { 470 | return snapshot_scan_keys_sync.call( 471 | this.boxed, 472 | start, 473 | end, 474 | limit, 475 | include_start, 476 | include_end 477 | ); 478 | } 479 | } 480 | 481 | export class TransactionClient { 482 | boxed: any; 483 | /** 484 | * @class TransactionClient 485 | * @param { string } pd_endpoint - PD endpoint 486 | * @example const client = new tikv.TransactionClient("127.0.0.1:2379"); 487 | */ 488 | constructor(pd_endpoint: string) { 489 | this.boxed = txn_connect_sync(pd_endpoint); 490 | } 491 | 492 | /** 493 | * Create a new 'begin' request. 494 | * @param { boolean } pessimistic - pessimistic 495 | * @example 496 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 497 | * const txn = client.begin(true); 498 | * txn.commit() 499 | */ 500 | begin(pessimistic: boolean) { 501 | return new Transaction(txn_begin_sync.call(this.boxed, pessimistic)); 502 | } 503 | 504 | /** 505 | * Create a new Snapshot 506 | * @param { number } timestamp - timestamp 507 | * @param { boolean } pessimistic - pessimistic 508 | * @example 509 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 510 | * const snapshot = client.snapshot(client.current_timestamp(), true); 511 | */ 512 | snapshot(timestamp: number, pessimistic: boolean) { 513 | return new Snapshot( 514 | txn_snapshot_sync.call(this.boxed, timestamp, pessimistic) 515 | ); 516 | } 517 | 518 | /** 519 | * Retrieve the current [`Timestamp`]. 520 | * @example 521 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 522 | * const timestamp = client.current_timestamp(); 523 | * //=> 1588888888 524 | */ 525 | current_timestamp() { 526 | return txn_current_timestamp_sync.call(this.boxed); 527 | } 528 | 529 | /** 530 | * Request garbage collection (GC) of the TiKV cluster. 531 | * @param { number } safepoint - safe point 532 | * @example 533 | * const client = new tikv.TransactionClient("127.0.0.1:2379"); 534 | * client.gc(1588888888); 535 | * //=> true 536 | */ 537 | gc(safepoint: number) { 538 | return txn_gc_sync.call(this.boxed, safepoint); 539 | } 540 | } 541 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es6", 4 | "module": "commonjs", 5 | "strict": true, 6 | "declaration": true, 7 | "outDir": "./dist", 8 | "esModuleInterop": true, 9 | }, 10 | "include": [ 11 | "tikv_client/**/*", 12 | "typing.d.ts" 13 | ], 14 | "exclude": [ 15 | "node_modules", 16 | "**/*.spec.ts" 17 | ] 18 | } --------------------------------------------------------------------------------