From a9aecb5b362fcbc00a9d8b04b8a8d476ad2ba1c4 Mon Sep 17 00:00:00 2001 From: Donovan Preston Date: Thu, 10 Oct 2019 13:39:56 -0400 Subject: [PATCH 1/5] Fix a comment saying the sync version is 1.6; we're actually still on 1.5 --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 40689eb9..006ac1f5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -//! Sync Storage Server for Sync 1.6 +//! Sync Storage Server for Sync 1.5 use std::error::Error; use docopt::Docopt; From 8a6cbd41404cd4b6bb2b35f903db35b466a72f9f Mon Sep 17 00:00:00 2001 From: Donovan Preston Date: Thu, 10 Oct 2019 15:30:02 -0400 Subject: [PATCH 2/5] Fix #221 Remove google-apis-rs support --- Cargo.lock | 136 ------------------------------- Cargo.toml | 19 +---- db-tests/Cargo.lock | 136 ------------------------------- db-tests/Cargo.toml | 2 - src/db/error.rs | 13 +-- src/db/spanner/manager.rs | 72 ++--------------- src/db/spanner/models.rs | 154 ++++-------------------------------- src/db/spanner/support.rs | 108 ++----------------------- src/db/spanner/test_util.rs | 3 - src/settings.rs | 7 +- 10 files changed, 31 insertions(+), 619 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index deacaa37..711c0ab8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -239,11 +239,6 @@ dependencies = [ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "antidote" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "arc-swap" version = "0.3.11" @@ -323,15 +318,6 @@ dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "base64" version = "0.10.1" @@ -925,20 +911,6 @@ name = "glob" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "google-spanner1" -version = "1.0.10+20190613" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "yup-oauth2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "googleapis-raw" version = "0.0.1" @@ -1074,24 +1046,6 @@ dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hyper" -version = "0.10.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "hyper" version = "0.12.35" @@ -1121,16 +1075,6 @@ dependencies = [ "want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hyper-native-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "hyper-tls" version = "0.3.2" @@ -1203,14 +1147,6 @@ dependencies = [ "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "itertools" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "itoa" version = "0.4.4" @@ -1293,14 +1229,6 @@ dependencies = [ "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "log" version = "0.4.8" @@ -1353,14 +1281,6 @@ dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mime" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "mime" version = "0.3.14" @@ -2007,11 +1927,6 @@ name = "ryu" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "safemem" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "same-file" version = "1.0.5" @@ -2401,7 +2316,6 @@ dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "google-spanner1 1.0.10+20190613 (registry+https://github.com/rust-lang/crates.io-index)", "googleapis-raw 0.0.1", "grpcio 0.5.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", "hawk 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2433,7 +2347,6 @@ dependencies = [ "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "validator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "validator_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "yup-oauth2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2688,11 +2601,6 @@ dependencies = [ "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "traitobject" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "trust-dns-proto" version = "0.7.4" @@ -2748,11 +2656,6 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "typeable" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "typenum" version = "1.11.2" @@ -2766,14 +2669,6 @@ dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "unicase" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicase" version = "2.5.1" @@ -3012,24 +2907,6 @@ dependencies = [ "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "yup-oauth2" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper-native-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [metadata] "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "checksum actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fade9bd4bb46bacde89f1e726c7a3dd230536092712f5d94d77ca57c087fca0" @@ -3046,7 +2923,6 @@ dependencies = [ "checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" "checksum adler32 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "7e522997b529f05601e05166c07ed17789691f562762c7f3b987263d2dedee5c" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5" "checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" "checksum arc-swap 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "854ede29f7a0ce90519fb2439d030320c6201119b87dab0ee96044603e1130b9" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" @@ -3057,7 +2933,6 @@ dependencies = [ "checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" "checksum bindgen 0.51.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18270cdd7065ec045a6bb4bdcd5144d14a78b3aedb3bc5111e688773ac8b9ad0" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" @@ -3125,7 +3000,6 @@ dependencies = [ "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -"checksum google-spanner1 1.0.10+20190613 (registry+https://github.com/rust-lang/crates.io-index)" = "ff0777f496d043e9c61b10f233b4dc5e2ced688662d07f293b37a86618666b9e" "checksum grpcio 0.5.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ba77e7b81b58a12e2dff1271c20a1f8cd74916de09355a5777470d911e8de41c" "checksum grpcio-sys 0.5.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0d2c6e956b8080cd5610a834bee17ab729d4cca2ce05db6987dfbeab18faf98d" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" @@ -3139,9 +3013,7 @@ dependencies = [ "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum httpdate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -"checksum hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" "checksum hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)" = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" -"checksum hyper-native-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d375598f442742b0e66208ee12501391f1c7ac0bafb90b4fe53018f81f06068" "checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" @@ -3150,7 +3022,6 @@ dependencies = [ "checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" -"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" @@ -3163,7 +3034,6 @@ dependencies = [ "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" @@ -3171,7 +3041,6 @@ dependencies = [ "checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" "checksum migrations_internals 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8089920229070f914b9ce9b07ef60e175b2b9bc2d35c3edd8bf4433604e863b9" "checksum migrations_macros 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1664412abf7db2b8a6d58be42a38b099780cc542b5b350383b805d88932833fe" -"checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" "checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" @@ -3243,7 +3112,6 @@ dependencies = [ "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" -"checksum safemem 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b08423011dae9a5ca23f07cf57dac3857f5c885d352b76f6d95f4aea9434d0" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" "checksum schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" "checksum scheduled-thread-pool 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd07742e081ff6c077f5f6b283f12f32b9e7cc765b316160d66289b74546fbb3" @@ -3309,15 +3177,12 @@ dependencies = [ "checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" "checksum tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f02298505547f73e60f568359ef0d016d5acd6e830ab9bc7c4a5b3403440121b" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5559ebdf6c2368ddd11e20b11d6bbaf9e46deb803acd7815e93f5a7b4a6d2901" "checksum trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9992e58dba365798803c0b91018ff6c8d3fc77e06977c4539af2a6bfe0a039" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" -"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" "checksum uname 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b72f89f0ca32e4db1c04e2a72f5345d59796d4866a1ee0609084569f73683dc8" -"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2e2e6bd1e59e56598518beb94fd6db628ded570326f0a98c679a304bd9f00150" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" @@ -3349,4 +3214,3 @@ dependencies = [ "checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" -"checksum yup-oauth2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "add0ccdddbb13a69ba8f7c4738bd6af551425889cc4633b6f8cb3034bb359b07" diff --git a/Cargo.toml b/Cargo.toml index 2b6d03ce..6bcdbf36 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,18 +30,15 @@ docopt = "1.1.0" env_logger = "0.6" failure = "0.1.5" futures = "0.1.28" -googleapis-raw = { version = "0", path = "../mozilla-rust-sdk/googleapis-raw", optional = true } -grpcio = { version = "0.5.0-alpha.1", optional = true } +googleapis-raw = { version = "0", path = "../mozilla-rust-sdk/googleapis-raw" } +grpcio = { version = "0.5.0-alpha.1" } lazy_static = "1.4.0" -# XXX: switch to this line google-apis-rs support -#hawk = { version = "3.0.0", default_features = false, features = ["use_openssl"] } hawk = "3.0.0" hkdf = "0.8.0" hmac = "0.7" log = "0.4" mime = "0.3" mozsvc-common = "0.1" -# num = "0.2.0" num_cpus = "1.10" protobuf = "2.7.0" rand = "0.7" @@ -65,17 +62,5 @@ uuid = { version = "0.7.4", features = ["serde", "v4"] } validator = "0.9" validator_derive = "0.9" -google-spanner1 = "1.0.10" -#google-spanner1 = { version = "*", path = "../google-apis-rs/gen/spanner1" } -# This project intentionally uses an old version of Hyper. See -# https://github.com/Byron/google-apis-rs/issues/173 for more -# information. -# XXX: switch these on for google-apis-rs support -#hyper = "^0.10" -#hyper-rustls = "^0.6" -yup-oauth2 = "^1.0" - [features] -default = ["google_grpc"] db_test = [] -google_grpc = ["googleapis-raw", "grpcio"] diff --git a/db-tests/Cargo.lock b/db-tests/Cargo.lock index 044091da..0c2be732 100644 --- a/db-tests/Cargo.lock +++ b/db-tests/Cargo.lock @@ -239,11 +239,6 @@ dependencies = [ "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "antidote" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "arc-swap" version = "0.3.11" @@ -323,15 +318,6 @@ dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "base64" -version = "0.9.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)", - "safemem 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "base64" version = "0.10.1" @@ -1015,20 +1001,6 @@ name = "glob" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "google-spanner1" -version = "1.0.10+20190613" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", - "yup-oauth2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "googleapis-raw" version = "0.0.1" @@ -1164,24 +1136,6 @@ dependencies = [ "quick-error 1.2.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hyper" -version = "0.10.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)", - "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", - "language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", - "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", - "traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "hyper" version = "0.12.35" @@ -1211,16 +1165,6 @@ dependencies = [ "want 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "hyper-native-tls" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", - "native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "hyper-tls" version = "0.3.2" @@ -1293,14 +1237,6 @@ dependencies = [ "winreg 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "itertools" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "itoa" version = "0.4.4" @@ -1383,14 +1319,6 @@ dependencies = [ "scopeguard 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "log" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "log" version = "0.4.8" @@ -1443,14 +1371,6 @@ dependencies = [ "syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "mime" -version = "0.2.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "mime" version = "0.3.14" @@ -2102,11 +2022,6 @@ name = "ryu" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "safemem" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "same-file" version = "1.0.5" @@ -2496,7 +2411,6 @@ dependencies = [ "env_logger 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)", - "google-spanner1 1.0.10+20190613 (registry+https://github.com/rust-lang/crates.io-index)", "googleapis-raw 0.0.1", "grpcio 0.5.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)", "hawk 3.0.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2528,7 +2442,6 @@ dependencies = [ "uuid 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)", "validator 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "validator_derive 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "yup-oauth2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -2783,11 +2696,6 @@ dependencies = [ "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "traitobject" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "trust-dns-proto" version = "0.7.4" @@ -2843,11 +2751,6 @@ dependencies = [ "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "typeable" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "typenum" version = "1.11.2" @@ -2861,14 +2764,6 @@ dependencies = [ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "unicase" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "unicase" version = "2.5.1" @@ -3107,24 +3002,6 @@ dependencies = [ "linked-hash-map 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "yup-oauth2" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)", - "chrono 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)", - "hyper-native-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", - "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", - "openssl 0.10.24 (registry+https://github.com/rust-lang/crates.io-index)", - "serde 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_derive 1.0.101 (registry+https://github.com/rust-lang/crates.io-index)", - "serde_json 1.0.40 (registry+https://github.com/rust-lang/crates.io-index)", - "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [metadata] "checksum actix-codec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "9f2c11af4b06dc935d8e1b1491dad56bfb32febc49096a91e773f8535c176453" "checksum actix-connect 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)" = "9fade9bd4bb46bacde89f1e726c7a3dd230536092712f5d94d77ca57c087fca0" @@ -3141,7 +3018,6 @@ dependencies = [ "checksum actix-web-codegen 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3fe9e3cdec1e645b675f354766e0688c5705021c85ab3cf739be1c8999b91c76" "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" -"checksum antidote 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "34fde25430d87a9388dadbe6e34d7f72a462c8b43ac8d309b42b0a8505d7e2a5" "checksum arc-swap 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "bc4662175ead9cd84451d5c35070517777949a2ed84551764129cedb88384841" "checksum arc-swap 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "854ede29f7a0ce90519fb2439d030320c6201119b87dab0ee96044603e1130b9" "checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee" @@ -3152,7 +3028,6 @@ dependencies = [ "checksum backtrace 0.3.37 (registry+https://github.com/rust-lang/crates.io-index)" = "5180c5a20655b14a819b652fd2378fa5f1697b6c9ddad3e695c2f9cedf6df4e2" "checksum backtrace-sys 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "82a830b4ef2d1124a711c71d263c5abdc710ef8e907bd508c88be475cebc422b" "checksum base64 0.10.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b25d992356d2eb0ed82172f5248873db5560c4721f564b13cb5193bda5e668e" -"checksum base64 0.9.3 (registry+https://github.com/rust-lang/crates.io-index)" = "489d6c0ed21b11d038c31b6ceccca973e65d73ba3bd8ecb9a2babf5546164643" "checksum bindgen 0.51.0 (registry+https://github.com/rust-lang/crates.io-index)" = "18270cdd7065ec045a6bb4bdcd5144d14a78b3aedb3bc5111e688773ac8b9ad0" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" "checksum blake2b_simd 0.5.8 (registry+https://github.com/rust-lang/crates.io-index)" = "5850aeee1552f495dd0250014cf64b82b7c8879a89d83b33bbdace2cc4f63182" @@ -3227,7 +3102,6 @@ dependencies = [ "checksum generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" "checksum getrandom 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "473a1265acc8ff1e808cd0a1af8cee3c2ee5200916058a2ca113c29f2d903571" "checksum glob 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" -"checksum google-spanner1 1.0.10+20190613 (registry+https://github.com/rust-lang/crates.io-index)" = "ff0777f496d043e9c61b10f233b4dc5e2ced688662d07f293b37a86618666b9e" "checksum grpcio 0.5.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "ba77e7b81b58a12e2dff1271c20a1f8cd74916de09355a5777470d911e8de41c" "checksum grpcio-sys 0.5.0-alpha.4 (registry+https://github.com/rust-lang/crates.io-index)" = "0d2c6e956b8080cd5610a834bee17ab729d4cca2ce05db6987dfbeab18faf98d" "checksum h2 0.1.26 (registry+https://github.com/rust-lang/crates.io-index)" = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" @@ -3241,9 +3115,7 @@ dependencies = [ "checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum httpdate 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "494b4d60369511e7dea41cf646832512a94e542f68bb9c49e54518e0f468eb47" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" -"checksum hyper 0.10.16 (registry+https://github.com/rust-lang/crates.io-index)" = "0a0652d9a2609a968c14be1a9ea00bf4b1d64e2e1f53a1b51b6fff3a6e829273" "checksum hyper 0.12.35 (registry+https://github.com/rust-lang/crates.io-index)" = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" -"checksum hyper-native-tls 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6d375598f442742b0e66208ee12501391f1c7ac0bafb90b4fe53018f81f06068" "checksum hyper-tls 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3a800d6aa50af4b5850b2b0f659625ce9504df908e9733b635720483be26174f" "checksum idna 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" @@ -3252,7 +3124,6 @@ dependencies = [ "checksum indexmap 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a61202fbe46c4a951e9404a720a0180bcf3212c750d735cb5c4ba4dc551299f3" "checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" "checksum ipconfig 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" -"checksum itertools 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b8467d9c1cebe26feb08c640139247fac215782d35371ade9a2136ed6085358" "checksum itoa 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "501266b7edd0174f8530248f87f99c88fbe60ca4ef3dd486835b8d8d53136f7f" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum language-tags 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" @@ -3265,7 +3136,6 @@ dependencies = [ "checksum lock_api 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "62ebf1391f6acad60e5c8b43706dde4582df75c06698ab44511d15016bc2442c" "checksum lock_api 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed946d4529956a20f2d63ebe1b69996d5a2137c91913fe3ebbeff957f5bca7ff" "checksum lock_api 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f8912e782533a93a167888781b836336a6ca5da6175c05944c86cf28c31104dc" -"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum lru-cache 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" "checksum matches 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" @@ -3273,7 +3143,6 @@ dependencies = [ "checksum memoffset 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce6075db033bbbb7ee5a0bbd3a3186bbae616f57fb001c485c7ff77955f8177f" "checksum migrations_internals 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8089920229070f914b9ce9b07ef60e175b2b9bc2d35c3edd8bf4433604e863b9" "checksum migrations_macros 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1664412abf7db2b8a6d58be42a38b099780cc542b5b350383b805d88932833fe" -"checksum mime 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ba626b8a6de5da682e1caa06bdb42a335aee5a84db8e5046a3e8ab17ba0a3ae0" "checksum mime 0.3.14 (registry+https://github.com/rust-lang/crates.io-index)" = "dd1d63acd1b78403cc0c325605908475dd9b9a3acbf65ed8bcab97e27014afcf" "checksum mime_guess 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1a0ed03949aef72dbdf3116a383d7b38b4768e6f960528cd6a6044aa9ed68599" "checksum miniz-sys 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "1e9e3ae51cea1576ceba0dde3d484d30e6e5b86dee0b2d412fe3a16a15c98202" @@ -3346,7 +3215,6 @@ dependencies = [ "checksum rustc-demangle 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "4c691c0e608126e00913e33f0ccf3727d5fc84573623b8d65b2df340b5201783" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c92464b447c0ee8c4fb3824ecc8383b81717b9f1e74ba2e72540aef7b9f82997" -"checksum safemem 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d2b08423011dae9a5ca23f07cf57dac3857f5c885d352b76f6d95f4aea9434d0" "checksum same-file 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "585e8ddcedc187886a30fa705c47985c3fa88d06624095856b36ca0b82ff4421" "checksum schannel 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)" = "87f550b06b6cba9c8b8be3ee73f391990116bf527450d2556e9b9ce263b9a021" "checksum scheduled-thread-pool 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bd07742e081ff6c077f5f6b283f12f32b9e7cc765b316160d66289b74546fbb3" @@ -3412,15 +3280,12 @@ dependencies = [ "checksum tokio-timer 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "f2106812d500ed25a4f38235b9cae8f78a09edf43203e16e59c3b769a342a60e" "checksum tokio-udp 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f02298505547f73e60f568359ef0d016d5acd6e830ab9bc7c4a5b3403440121b" "checksum toml 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "758664fc71a3a69038656bee8b6be6477d2a6c315a6b81f7081f591bffa4111f" -"checksum traitobject 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "efd1f82c56340fdf16f2a953d7bda4f8fdffba13d93b00844c25572110b26079" "checksum trust-dns-proto 0.7.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5559ebdf6c2368ddd11e20b11d6bbaf9e46deb803acd7815e93f5a7b4a6d2901" "checksum trust-dns-resolver 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)" = "6c9992e58dba365798803c0b91018ff6c8d3fc77e06977c4539af2a6bfe0a039" "checksum try-lock 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" "checksum try_from 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "283d3b89e1368717881a9d51dad843cc435380d8109c9e47d38780a324698d8b" -"checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" "checksum uname 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b72f89f0ca32e4db1c04e2a72f5345d59796d4866a1ee0609084569f73683dc8" -"checksum unicase 1.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7f4765f83163b74f957c797ad9253caf97f103fb064d3999aea9568d09fc8a33" "checksum unicase 2.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2e2e6bd1e59e56598518beb94fd6db628ded570326f0a98c679a304bd9f00150" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "141339a08b982d942be2ca06ff8b076563cbe223d1befd5450716790d44e2426" @@ -3452,4 +3317,3 @@ dependencies = [ "checksum winutil 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7daf138b6b14196e3830a588acf1e86966c694d3e8fb026fb105b8b5dca07e6e" "checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" "checksum yaml-rust 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "65923dd1784f44da1d2c3dbbc5e822045628c590ba72123e1c73d3c230c4434d" -"checksum yup-oauth2 1.0.12 (registry+https://github.com/rust-lang/crates.io-index)" = "add0ccdddbb13a69ba8f7c4738bd6af551425889cc4633b6f8cb3034bb359b07" diff --git a/db-tests/Cargo.toml b/db-tests/Cargo.toml index 8372fb2b..f3e521dc 100644 --- a/db-tests/Cargo.toml +++ b/db-tests/Cargo.toml @@ -12,5 +12,3 @@ lazy_static = "1.3.0" rand = "0.6.5" syncstorage = { version = "0.1.0", path = "../", features = ["db_test"] } -[features] -google_grpc = ["syncstorage/google_grpc"] diff --git a/src/db/error.rs b/src/db/error.rs index d02d1463..22330943 100644 --- a/src/db/error.rs +++ b/src/db/error.rs @@ -90,8 +90,6 @@ impl From> for DbError { #[derive(Debug)] pub enum ConnectionError { Diesel(diesel::result::ConnectionError), - Spanner(String), - #[cfg(feature = "google_grpc")] SpannerGrpc(grpcio::Error), } @@ -99,8 +97,6 @@ impl fmt::Display for ConnectionError { fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { match self { ConnectionError::Diesel(e) => fmt::Display::fmt(e, formatter), - ConnectionError::Spanner(msg) => fmt::Display::fmt(msg, formatter), - #[cfg(feature = "google_grpc")] ConnectionError::SpannerGrpc(e) => fmt::Display::fmt(e, formatter), } } @@ -112,14 +108,7 @@ from_error!(diesel::result::Error, DbError, DbErrorKind::Query); from_error!(diesel::result::ConnectionError, DbError, |inner| { DbErrorKind::Connection(ConnectionError::Diesel(inner)) }); -from_error!( - google_spanner1::Error, - DbError, - |inner: google_spanner1::Error| DbErrorKind::Connection(ConnectionError::Spanner( - inner.to_string() - )) -); -#[cfg(feature = "google_grpc")] + from_error!(grpcio::Error, DbError, |inner: grpcio::Error| { // Convert ABORTED (typically due to a transaction abort) into 503s match inner { diff --git a/src/db/spanner/manager.rs b/src/db/spanner/manager.rs index bc35cef0..d35bb0e9 100644 --- a/src/db/spanner/manager.rs +++ b/src/db/spanner/manager.rs @@ -1,18 +1,14 @@ use diesel::r2d2::ManageConnection; -#[cfg(not(feature = "google_grpc"))] -use google_spanner1::{CreateSessionRequest, Session, Spanner}; -#[cfg(not(feature = "google_grpc"))] -use hyper::{net::HttpsConnector, Client}; -#[cfg(not(feature = "google_grpc"))] -use hyper_rustls::TlsClient; -#[cfg(not(feature = "google_grpc"))] -use yup_oauth2::{service_account_key_from_file, GetToken, ServiceAccountAccess}; use crate::{ db::error::{DbError, DbErrorKind}, settings::Settings, }; +use googleapis_raw::spanner::v1::spanner_grpc::SpannerClient; + +use googleapis_raw::spanner::v1::spanner::{CreateSessionRequest, ExecuteSqlRequest, Session}; + #[derive(Debug)] pub struct SpannerConnectionManager { database_name: String, @@ -30,28 +26,17 @@ impl SpannerConnectionManager { } pub struct SpannerSession { - #[cfg(feature = "google_grpc")] - pub client: googleapis_raw::spanner::v1::spanner_grpc::SpannerClient, - #[cfg(feature = "google_grpc")] - pub session: googleapis_raw::spanner::v1::spanner::Session, - - #[cfg(not(feature = "google_grpc"))] - pub hub: Spanner>, - #[cfg(not(feature = "google_grpc"))] + pub client: SpannerClient, pub session: Session, pub(super) use_test_transactions: bool, } -#[cfg(feature = "google_grpc")] impl ManageConnection for SpannerConnectionManager { type Connection = SpannerSession; type Error = grpcio::Error; fn connect(&self) -> Result { - use googleapis_raw::spanner::v1::{ - spanner::CreateSessionRequest, spanner_grpc::SpannerClient, - }; use grpcio::{CallOption, ChannelBuilder, ChannelCredentials, EnvBuilder, MetadataBuilder}; use std::sync::Arc; @@ -87,7 +72,7 @@ impl ManageConnection for SpannerConnectionManager { } fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error> { - let mut req = googleapis_raw::spanner::v1::spanner::ExecuteSqlRequest::new(); + let mut req = ExecuteSqlRequest::new(); req.set_sql("SELECT 1".to_owned()); req.set_session(conn.session.get_name().to_owned()); conn.client.execute_sql(&req)?; @@ -98,48 +83,3 @@ impl ManageConnection for SpannerConnectionManager { false } } - -#[cfg(not(feature = "google_grpc"))] -impl ManageConnection for SpannerConnectionManager { - type Connection = SpannerSession; - type Error = google_spanner1::Error; - - fn connect(&self) -> Result { - let secret = service_account_key_from_file(&String::from("service-account.json")).unwrap(); - let client = Client::with_connector(HttpsConnector::new(TlsClient::new())); - let mut access = ServiceAccountAccess::new(secret, client); - let _token = access - .token(&vec!["https://www.googleapis.com/auth/spanner.data"]) - .unwrap(); - // println!("{:?}", token); - let client2 = Client::with_connector(HttpsConnector::new(TlsClient::new())); - let hub = Spanner::new(client2, access); - let req = CreateSessionRequest::default(); - let session = hub - .projects() - .instances_databases_sessions_create(req, &self.database_name) - .doit()? - .1; - Ok(SpannerSession { - hub, - session, - use_test_transactions: false, - }) - } - - fn is_valid(&self, conn: &mut Self::Connection) -> Result<(), Self::Error> { - use google_spanner1::ExecuteSqlRequest; - let mut request = ExecuteSqlRequest::default(); - request.sql = Some("SELECT 1".to_owned()); - let session = conn.session.name.as_ref().unwrap(); - conn.hub - .projects() - .instances_databases_sessions_execute_sql(request, session) - .doit()?; - Ok(()) - } - - fn has_broken(&self, _conn: &mut Self::Connection) -> bool { - false - } -} diff --git a/src/db/spanner/models.rs b/src/db/spanner/models.rs index b617de6b..c8881f68 100644 --- a/src/db/spanner/models.rs +++ b/src/db/spanner/models.rs @@ -28,16 +28,15 @@ use super::{ support::{as_list_value, as_value, bso_from_row, ExecuteSqlRequestBuilder}, }; -#[cfg(not(feature = "google_grpc"))] -use google_spanner1::{ - BeginTransactionRequest, CommitRequest, ExecuteSqlRequest, ReadOnly, ReadWrite, - RollbackRequest, TransactionOptions, +use googleapis_raw::spanner::v1::spanner::{ + BeginTransactionRequest, CommitRequest, ExecuteSqlRequest, RollbackRequest, +}; +use googleapis_raw::spanner::v1::transaction; +use googleapis_raw::spanner::v1::transaction::{ + TransactionOptions, TransactionOptions_ReadOnly, TransactionOptions_ReadWrite, }; -#[cfg(feature = "google_grpc")] -pub type TransactionSelector = googleapis_raw::spanner::v1::transaction::TransactionSelector; -#[cfg(not(feature = "google_grpc"))] -pub type TransactionSelector = google_spanner1::TransactionSelector; +pub type TransactionSelector = transaction::TransactionSelector; #[derive(Debug, Eq, PartialEq)] pub enum CollectionLock { @@ -63,9 +62,6 @@ struct SpannerDbSession { coll_modified_cache: HashMap<(HawkIdentifier, i32), SyncTimestamp>, /// Currently locked collections coll_locks: HashMap<(HawkIdentifier, i32), CollectionLock>, - #[cfg(feature = "google_grpc")] - transaction: Option, - #[cfg(not(feature = "google_grpc"))] transaction: Option, in_write_transaction: bool, execute_sql_count: u64, @@ -286,57 +282,26 @@ impl SpannerDb { self.session.borrow_mut().timestamp = Some(timestamp); } - #[cfg(feature = "google_grpc")] pub(super) fn begin(&self, for_write: bool) -> Result<()> { let spanner = &self.conn; - let mut options = googleapis_raw::spanner::v1::transaction::TransactionOptions::new(); + let mut options = TransactionOptions::new(); if for_write { - options.set_read_write( - googleapis_raw::spanner::v1::transaction::TransactionOptions_ReadWrite::new(), - ); + options.set_read_write(TransactionOptions_ReadWrite::new()); self.session.borrow_mut().in_write_transaction = true; } else { - options.set_read_only( - googleapis_raw::spanner::v1::transaction::TransactionOptions_ReadOnly::new(), - ); + options.set_read_only(TransactionOptions_ReadOnly::new()); } - let mut req = googleapis_raw::spanner::v1::spanner::BeginTransactionRequest::new(); + let mut req = BeginTransactionRequest::new(); req.set_session(spanner.session.get_name().to_owned()); req.set_options(options); let mut transaction = spanner.client.begin_transaction(&req)?; - let mut ts = googleapis_raw::spanner::v1::transaction::TransactionSelector::new(); + let mut ts = TransactionSelector::new(); ts.set_id(transaction.take_id()); self.session.borrow_mut().transaction = Some(ts); Ok(()) } - #[cfg(not(feature = "google_grpc"))] - pub(super) fn begin(&self, for_write: bool) -> Result<()> { - let spanner = &self.conn; - let session = spanner.session.name.as_ref().unwrap(); - let mut options = TransactionOptions::default(); - if for_write { - options.read_write = Some(ReadWrite::default()); - self.session.borrow_mut().in_write_transaction = true; - } else { - options.read_only = Some(ReadOnly::default()); - } - let req = BeginTransactionRequest { - options: Some(options), - }; - let (_, transaction) = spanner - .hub - .projects() - .instances_databases_sessions_begin_transaction(req, session) - .doit()?; - self.session.borrow_mut().transaction = Some(google_spanner1::TransactionSelector { - id: transaction.id, - ..Default::default() - }); - Ok(()) - } - /// Return the current transaction metadata (TransactionSelector) if one is active. fn get_transaction(&self) -> Result> { Ok(if self.session.borrow().transaction.is_some() { @@ -347,12 +312,8 @@ impl SpannerDb { }) } - #[cfg(feature = "google_grpc")] - fn sql_request( - &self, - sql: &str, - ) -> Result { - let mut sqlr = googleapis_raw::spanner::v1::spanner::ExecuteSqlRequest::new(); + fn sql_request(&self, sql: &str) -> Result { + let mut sqlr = ExecuteSqlRequest::new(); sqlr.set_sql(sql.to_owned()); if let Some(transaction) = self.get_transaction()? { sqlr.set_transaction(transaction); @@ -366,20 +327,6 @@ impl SpannerDb { Ok(sqlr) } - #[cfg(not(feature = "google_grpc"))] - fn sql_request(&self, sql: &str) -> Result { - let mut sqlr = ExecuteSqlRequest::default(); - sqlr.sql = Some(sql.to_owned()); - let transaction = self.get_transaction()?; - if transaction.is_some() { - sqlr.transaction = transaction; - let mut session = self.session.borrow_mut(); - sqlr.seqno = Some(session.execute_sql_count.to_string()); - session.execute_sql_count += 1; - } - Ok(sqlr) - } - pub fn sql(&self, sql: &str) -> Result { Ok(ExecuteSqlRequestBuilder::new(self.sql_request(sql)?)) } @@ -388,7 +335,6 @@ impl SpannerDb { self.session.borrow().in_write_transaction } - #[cfg(feature = "google_grpc")] pub fn commit_sync(&self) -> Result<()> { if !self.in_write_transaction() { // read-only @@ -403,7 +349,7 @@ impl SpannerDb { } if let Some(transaction) = self.get_transaction()? { - let mut req = googleapis_raw::spanner::v1::spanner::CommitRequest::new(); + let mut req = CommitRequest::new(); req.set_session(spanner.session.get_name().to_owned()); req.set_transaction_id(transaction.get_id().to_vec()); spanner.client.commit(&req)?; @@ -413,40 +359,6 @@ impl SpannerDb { } } - #[cfg(not(feature = "google_grpc"))] - pub fn commit_sync(&self) -> Result<()> { - if !self.in_write_transaction() { - // read-only - return Ok(()); - } - - let spanner = &self.conn; - - if cfg!(any(test, feature = "db_test")) && spanner.use_test_transactions { - // don't commit test transactions - return Ok(()); - } - - if let Some(transaction) = self.get_transaction()? { - let session = spanner.session.name.as_ref().unwrap(); - spanner - .hub - .projects() - .instances_databases_sessions_commit( - CommitRequest { - transaction_id: transaction.id, - ..Default::default() - }, - session, - ) - .doit()?; - Ok(()) - } else { - Err(DbError::internal("No transaction to commit"))? - } - } - - #[cfg(feature = "google_grpc")] pub fn rollback_sync(&self) -> Result<()> { if !self.in_write_transaction() { // read-only @@ -455,7 +367,7 @@ impl SpannerDb { if let Some(transaction) = self.get_transaction()? { let spanner = &self.conn; - let mut req = googleapis_raw::spanner::v1::spanner::RollbackRequest::new(); + let mut req = RollbackRequest::new(); req.set_session(spanner.session.get_name().to_owned()); req.set_transaction_id(transaction.get_id().to_vec()); spanner.client.rollback(&req)?; @@ -465,32 +377,6 @@ impl SpannerDb { } } - #[cfg(not(feature = "google_grpc"))] - pub fn rollback_sync(&self) -> Result<()> { - if !self.in_write_transaction() { - // read-only - return Ok(()); - } - - if let Some(transaction) = self.get_transaction()? { - let spanner = &self.conn; - let session = spanner.session.name.as_ref().unwrap(); - spanner - .hub - .projects() - .instances_databases_sessions_rollback( - RollbackRequest { - transaction_id: transaction.id, - }, - session, - ) - .doit()?; - Ok(()) - } else { - Err(DbError::internal("No transaction to rollback"))? - } - } - pub fn get_collection_timestamp_sync( &self, params: params::GetCollectionTimestamp, @@ -1200,8 +1086,6 @@ impl SpannerDb { }; if use_sortindex { - // special handling for google_grpc (null) - #[cfg(feature = "google_grpc")] let sortindex = bso .sortindex .map(|sortindex| as_value(sortindex.to_string())) @@ -1212,12 +1096,6 @@ impl SpannerDb { value }); - #[cfg(not(feature = "google_grpc"))] - let sortindex = bso - .sortindex - .map(|sortindex| sortindex.to_string()) - .unwrap_or_else(|| "NULL".to_owned()); - sqlparams.insert("sortindex".to_string(), sortindex); sqltypes.insert("sortindex".to_string(), SpannerType::Int64.into()); } diff --git a/src/db/spanner/support.rs b/src/db/spanner/support.rs index a198b518..e1b70690 100644 --- a/src/db/spanner/support.rs +++ b/src/db/spanner/support.rs @@ -1,6 +1,5 @@ use std::collections::HashMap; -#[cfg(feature = "google_grpc")] use protobuf::well_known_types::Struct; use protobuf::{ well_known_types::{ListValue, Value}, @@ -10,48 +9,26 @@ use protobuf::{ use super::models::{Conn, Result}; use crate::db::{results, util::SyncTimestamp, DbError, DbErrorKind}; -#[cfg(feature = "google_grpc")] +use googleapis_raw::spanner::v1::type_pb::{Type, TypeCode}; + type ParamValue = protobuf::well_known_types::Value; -#[cfg(not(feature = "google_grpc"))] -type ParamValue = String; -#[cfg(feature = "google_grpc")] type ParamType = googleapis_raw::spanner::v1::type_pb::Type; -#[cfg(not(feature = "google_grpc"))] -type ParamType = google_spanner1::Type; -#[cfg(feature = "google_grpc")] pub type ExecuteSqlRequest = googleapis_raw::spanner::v1::spanner::ExecuteSqlRequest; -#[cfg(not(feature = "google_grpc"))] -pub type ExecuteSqlRequest = google_spanner1::ExecuteSqlRequest; -#[cfg(feature = "google_grpc")] type ResultSet = googleapis_raw::spanner::v1::result_set::ResultSet; -#[cfg(not(feature = "google_grpc"))] -type ResultSet = google_spanner1::ResultSet; -#[cfg(feature = "google_grpc")] type ResultSetMetadata = googleapis_raw::spanner::v1::result_set::ResultSetMetadata; -#[cfg(not(feature = "google_grpc"))] -type ResultSetMetadata = google_spanner1::ResultSetMetadata; -#[cfg(feature = "google_grpc")] type ResultSetStats = googleapis_raw::spanner::v1::result_set::ResultSetStats; -#[cfg(not(feature = "google_grpc"))] -type ResultSetStats = google_spanner1::ResultSetStats; -#[cfg(feature = "google_grpc")] pub fn as_value(string_value: String) -> protobuf::well_known_types::Value { let mut value = Value::new(); value.set_string_value(string_value); value } -#[cfg(not(feature = "google_grpc"))] -pub fn as_value(string_value: String) -> String { - string_value -} - pub fn as_list_value( string_values: impl Iterator, ) -> protobuf::well_known_types::Value { @@ -79,11 +56,9 @@ pub enum SpannerType { Struct, } -#[cfg(feature = "google_grpc")] -impl Into for SpannerType { - fn into(self) -> googleapis_raw::spanner::v1::type_pb::Type { - let mut t = googleapis_raw::spanner::v1::type_pb::Type::new(); - use googleapis_raw::spanner::v1::type_pb::TypeCode; +impl Into for SpannerType { + fn into(self) -> Type { + let mut t = Type::new(); let code = match self { SpannerType::TypeCodeUnspecified => TypeCode::TYPE_CODE_UNSPECIFIED, SpannerType::Bool => TypeCode::BOOL, @@ -101,27 +76,6 @@ impl Into for SpannerType { } } -impl Into for SpannerType { - fn into(self) -> google_spanner1::Type { - let code = match self { - SpannerType::TypeCodeUnspecified => "TYPE_CODE_UNSPECIFIED", - SpannerType::Bool => "BOOL", - SpannerType::Int64 => "INT64", - SpannerType::Float64 => "FLOAT64", - SpannerType::Timestamp => "TIMESTAMP", - SpannerType::Date => "DATE", - SpannerType::String => "STRING", - SpannerType::Bytes => "BYTES", - SpannerType::Array => "ARRAY", - SpannerType::Struct => "STRUCT", - }; - google_spanner1::Type { - code: Some(code.to_owned()), - ..Default::default() - } - } -} - #[derive(Default)] pub struct ExecuteSqlRequestBuilder { execute_sql: ExecuteSqlRequest, @@ -147,7 +101,6 @@ impl ExecuteSqlRequestBuilder { self } - #[cfg(feature = "google_grpc")] pub fn execute(self, spanner: &Conn) -> Result { let mut request = self.execute_sql; request.set_session(spanner.session.get_name().to_owned()); @@ -162,24 +115,6 @@ impl ExecuteSqlRequestBuilder { let result = spanner.client.execute_sql(&request)?; Ok(SyncResultSet { result }) } - - #[cfg(not(feature = "google_grpc"))] - pub fn execute(self, spanner: &Conn) -> Result { - let session = spanner - .session - .name - .as_ref() - .ok_or_else(|| DbError::internal("No spanner session"))?; - let mut request = self.execute_sql; - request.params = self.params; - request.param_types = self.param_types; - let (_, result) = spanner - .hub - .projects() - .instances_databases_sessions_execute_sql(request, session) - .doit()?; - Ok(SyncResultSet { result }) - } } pub struct SyncResultSet { @@ -223,7 +158,6 @@ impl SyncResultSet { } } - #[cfg(feature = "google_grpc")] pub fn affected_rows(self: &SyncResultSet) -> Result { let stats = self .stats() @@ -233,7 +167,6 @@ impl SyncResultSet { } } -#[cfg(feature = "google_grpc")] impl Iterator for SyncResultSet { type Item = Vec; @@ -253,37 +186,6 @@ impl Iterator for SyncResultSet { } } -#[cfg(not(feature = "google_grpc"))] -impl Iterator for SyncResultSet { - type Item = Vec; - - fn next(&mut self) -> Option { - if let Some(rows) = self.result.rows.as_mut() { - if rows.is_empty() { - None - } else { - let row = rows.remove(0); - Some( - row.into_iter() - .map(|s| { - let mut value = Value::new(); - value.set_string_value(s); - value - }) - .collect(), - ) - } - } else { - None - } - } - - fn size_hint(&self) -> (usize, Option) { - let len = self.result.rows.len(); - (len, Some(len)) - } -} - pub fn bso_from_row(row: Vec) -> Result { Ok(results::GetBso { id: row[0].get_string_value().to_owned(), diff --git a/src/db/spanner/test_util.rs b/src/db/spanner/test_util.rs index d2758fc1..fd78f6bf 100644 --- a/src/db/spanner/test_util.rs +++ b/src/db/spanner/test_util.rs @@ -1,7 +1,4 @@ use diesel::r2d2::CustomizeConnection; -#[cfg(not(feature = "google_grpc"))] -use google_spanner1::Error; -#[cfg(feature = "google_grpc")] use grpcio::Error; use super::manager::SpannerSession; diff --git a/src/settings.rs b/src/settings.rs index bb84fa20..d0d708c7 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -134,12 +134,7 @@ impl Settings { let db = Url::parse(&self.database_url) .map(|url| url.scheme().to_owned()) .unwrap_or_else(|_| "".to_owned()); - let features = if cfg!(feature = "google_grpc") { - "+google_grpc" - } else { - "" - }; - format!("http://{}:{} ({}{})", self.host, self.port, db, features) + format!("http://{}:{} ({})", self.host, self.port, db) } } From 53292fc9c77394441ff8b6575943ad8e22883b75 Mon Sep 17 00:00:00 2001 From: jrconlin Date: Thu, 10 Oct 2019 17:35:09 -0700 Subject: [PATCH 3/5] bug: Be more permissive about content type headers Closes #264 --- src/web/extractors.rs | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/web/extractors.rs b/src/web/extractors.rs index cd626503..70cc21c3 100644 --- a/src/web/extractors.rs +++ b/src/web/extractors.rs @@ -87,6 +87,19 @@ impl BatchBsoBody { } } +fn get_content_type(headers: &HeaderMap, default: &HeaderValue) -> String { + let ct_raw = String::from_utf8( + headers + .get(CONTENT_TYPE) + .unwrap_or(&default) + .as_bytes() + .to_vec(), + ) + .unwrap_or_else(|_| "invalid".to_owned()); + let ct_parts: Vec<&str> = ct_raw.split(';').collect(); + ct_parts[0].to_owned() +} + #[derive(Default, Deserialize)] pub struct BsoBodies { pub valid: Vec, @@ -111,10 +124,10 @@ impl FromRequest for BsoBodies { // Only try and parse the body if its a valid content-type let headers = req.headers(); let default = HeaderValue::from_static(""); - let content_type = headers.get(CONTENT_TYPE).unwrap_or(&default).as_bytes(); + let content_type = get_content_type(headers, &default); - match content_type { - b"application/json" | b"text/plain" | b"application/newlines" | b"" => (), + match content_type.as_str() { + "application/json" | "text/plain" | "application/newlines" | "" => (), _ => { return Box::new(future::err( ValidationErrorKind::FromDetails( @@ -150,7 +163,7 @@ impl FromRequest for BsoBodies { // Define a new bool to check from a static closure to release the reference on the // content_type header - let newlines: bool = content_type == b"application/newlines"; + let newlines: bool = content_type == "application/newlines"; // Grab the max sizes let state = match req.app_data::() { @@ -289,8 +302,9 @@ impl FromRequest for BsoBody { let headers = req.headers(); let default = HeaderValue::from_static(""); - match headers.get(CONTENT_TYPE).unwrap_or(&default).as_bytes() { - b"application/json" | b"text/plain" | b"" => (), + let content_type = get_content_type(&headers, &default); + match content_type.as_str() { + "application/json" | "text/plain" | "" => (), _ => { return Box::new(future::err( ValidationErrorKind::FromDetails( From 914bb339e97fea762ee0be03994c17b1b0d843b1 Mon Sep 17 00:00:00 2001 From: jrconlin Date: Fri, 11 Oct 2019 10:19:52 -0700 Subject: [PATCH 4/5] f make more generic * add test --- src/web/extractors.rs | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/src/web/extractors.rs b/src/web/extractors.rs index 70cc21c3..58ba3068 100644 --- a/src/web/extractors.rs +++ b/src/web/extractors.rs @@ -8,7 +8,7 @@ use actix_web::{ dev::{ConnectionInfo, Extensions, Payload}, error::ErrorInternalServerError, http::{ - header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE}, + header::{HeaderMap, HeaderName, HeaderValue, ACCEPT, CONTENT_TYPE}, Uri, }, web::{Json, Query}, @@ -87,17 +87,11 @@ impl BatchBsoBody { } } -fn get_content_type(headers: &HeaderMap, default: &HeaderValue) -> String { - let ct_raw = String::from_utf8( - headers - .get(CONTENT_TYPE) - .unwrap_or(&default) - .as_bytes() - .to_vec(), - ) - .unwrap_or_else(|_| "invalid".to_owned()); +fn get_trimmed_header(headers: &HeaderMap, key: HeaderName, default: &HeaderValue) -> String { + let ct_raw = std::str::from_utf8(headers.get(key).unwrap_or(&default).as_bytes()) + .unwrap_or_else(|_| "invalid"); let ct_parts: Vec<&str> = ct_raw.split(';').collect(); - ct_parts[0].to_owned() + ct_parts[0].trim_end().to_owned() } #[derive(Default, Deserialize)] @@ -124,14 +118,16 @@ impl FromRequest for BsoBodies { // Only try and parse the body if its a valid content-type let headers = req.headers(); let default = HeaderValue::from_static(""); - let content_type = get_content_type(headers, &default); + let content_type = get_trimmed_header(headers, CONTENT_TYPE, &default); + + dbg!(&content_type); match content_type.as_str() { "application/json" | "text/plain" | "application/newlines" | "" => (), _ => { return Box::new(future::err( ValidationErrorKind::FromDetails( - "Invalid Content-Type".to_owned(), + format!("Invalid Content-Type {:?}", content_type), RequestErrorLocation::Header, Some("Content-Type".to_owned()), ) @@ -302,7 +298,7 @@ impl FromRequest for BsoBody { let headers = req.headers(); let default = HeaderValue::from_static(""); - let content_type = get_content_type(&headers, &default); + let content_type = get_trimmed_header(&headers, CONTENT_TYPE, &default); match content_type.as_str() { "application/json" | "text/plain" | "" => (), _ => { @@ -564,10 +560,12 @@ impl FromRequest for CollectionRequest { let db = >::from_request(req, payload)?; let query = BsoQueryParams::from_request(req, payload)?; let collection = CollectionParam::from_request(req, payload)?.collection; - let reply = match req.headers().get(ACCEPT) { - Some(v) if v.as_bytes() == b"application/newlines" => ReplyFormat::Newlines, - Some(v) if v.as_bytes() == b"application/json" => ReplyFormat::Json, - Some(_) => { + let content_type = + get_trimmed_header(&req.headers(), ACCEPT, &HeaderValue::from_static("")); + let reply = match content_type.as_str() { + "application/newlines" => ReplyFormat::Newlines, + "application/json" | "" => ReplyFormat::Json, + _ => { return Err(ValidationErrorKind::FromDetails( "Invalid accept".to_string(), RequestErrorLocation::Header, @@ -575,7 +573,6 @@ impl FromRequest for CollectionRequest { ) .into()); } - None => ReplyFormat::Json, }; Ok(CollectionRequest { @@ -1489,7 +1486,8 @@ mod tests { .data(state) .method(Method::POST) .header("authorization", header) - .header("content-type", "application/json") + .header("content-type", "application/json; charset=UTF-8") + .header("accept", "application/json;q=0.9,/;q=0.2") //.set_json(body) .set_payload(bod_str.as_bytes()) .param("uid", &USER_ID_STR) @@ -1676,6 +1674,7 @@ mod tests { let req = TestRequest::with_uri(&uri) .data(state) .header("authorization", header) + .header("accept", "application/json;a=0.9,/;q=0.2") .method(Method::GET) .param("uid", &USER_ID_STR) .param("collection", "tabs") From a25a62881b12f29506511d4a5018167eac4fff7b Mon Sep 17 00:00:00 2001 From: Philip Jenvey Date: Thu, 10 Oct 2019 15:05:35 -0700 Subject: [PATCH 5/5] feat: rewrite post/put_bsos w/ spanner mutations leaving the old impl. behind a cfg toggle for the db_tests (for now) also add a UNIQUE index on collection names Closes #267 --- spanner-2019-10-01.ddl | 6 +- src/db/spanner/models.rs | 174 ++++++++++++++++++++++++++++++++++++-- src/db/spanner/support.rs | 80 ++++++++++++++++++ 3 files changed, 252 insertions(+), 8 deletions(-) diff --git a/spanner-2019-10-01.ddl b/spanner-2019-10-01.ddl index e1717dc6..19912d23 100644 --- a/spanner-2019-10-01.ddl +++ b/spanner-2019-10-01.ddl @@ -25,7 +25,8 @@ CREATE TABLE bso ( ON bso(fxa_uid, fxa_kid, collection_id, modified DESC, expiry), INTERLEAVE IN user_collections; - CREATE INDEX BsoExpiry ON bso(expiry); + CREATE INDEX BsoExpiry + ON bso(expiry); CREATE TABLE collections ( @@ -33,6 +34,9 @@ CREATE TABLE collections ( name STRING(MAX) NOT NULL, ) PRIMARY KEY(id); + CREATE UNIQUE INDEX CollectionName + ON collections(name); + CREATE TABLE batches ( fxa_uid STRING(MAX) NOT NULL, diff --git a/src/db/spanner/models.rs b/src/db/spanner/models.rs index c8881f68..29a7a95b 100644 --- a/src/db/spanner/models.rs +++ b/src/db/spanner/models.rs @@ -17,24 +17,28 @@ use super::support::SpannerType; use crate::db::{ error::{DbError, DbErrorKind}, params, results, - util::{to_rfc3339, SyncTimestamp}, + util::SyncTimestamp, Db, DbFuture, Sorting, FIRST_CUSTOM_COLLECTION_ID, }; use crate::web::extractors::{BsoQueryParams, HawkIdentifier}; +#[cfg(not(any(test, feature = "db_test")))] +use super::support::{bso_to_insert_row, bso_to_update_row}; use super::{ batch, support::{as_list_value, as_value, bso_from_row, ExecuteSqlRequestBuilder}, }; -use googleapis_raw::spanner::v1::spanner::{ - BeginTransactionRequest, CommitRequest, ExecuteSqlRequest, RollbackRequest, -}; use googleapis_raw::spanner::v1::transaction; use googleapis_raw::spanner::v1::transaction::{ TransactionOptions, TransactionOptions_ReadOnly, TransactionOptions_ReadWrite, }; +use googleapis_raw::spanner::v1::{ + mutation::{Mutation, Mutation_Write}, + spanner::{BeginTransactionRequest, CommitRequest, ExecuteSqlRequest, RollbackRequest}, +}; +use protobuf::{well_known_types::ListValue, RepeatedField}; pub type TransactionSelector = transaction::TransactionSelector; @@ -48,7 +52,7 @@ pub(super) type Conn = PooledConnection; pub type Result = std::result::Result; /// The ttl to use for rows that are never supposed to expire (in seconds) -pub const DEFAULT_BSO_TTL: i64 = 2_100_000_000; +pub const DEFAULT_BSO_TTL: u32 = 2_100_000_000; pub const TOMBSTONE: i32 = 0; @@ -63,6 +67,9 @@ struct SpannerDbSession { /// Currently locked collections coll_locks: HashMap<(HawkIdentifier, i32), CollectionLock>, transaction: Option, + /// Behind Vec so commit can take() it (maybe commit() should consume self + /// instead?) + mutations: Option>, in_write_transaction: bool, execute_sql_count: u64, } @@ -327,10 +334,58 @@ impl SpannerDb { Ok(sqlr) } - pub fn sql(&self, sql: &str) -> Result { + pub(super) fn sql(&self, sql: &str) -> Result { Ok(ExecuteSqlRequestBuilder::new(self.sql_request(sql)?)) } + #[cfg(not(any(test, feature = "db_test")))] + pub(super) fn insert(&self, table: &str, columns: &[&str], values: Vec) { + let mut mutation = Mutation::new(); + mutation.set_insert(self.mutation_write(table, columns, values)); + self.session + .borrow_mut() + .mutations + .get_or_insert_with(|| vec![]) + .push(mutation); + } + + #[cfg(not(any(test, feature = "db_test")))] + pub(super) fn update(&self, table: &str, columns: &[&str], values: Vec) { + let mut mutation = Mutation::new(); + mutation.set_update(self.mutation_write(table, columns, values)); + self.session + .borrow_mut() + .mutations + .get_or_insert_with(|| vec![]) + .push(mutation); + } + + #[allow(unused)] + pub(super) fn insert_or_update(&self, table: &str, columns: &[&str], values: Vec) { + let mut mutation = Mutation::new(); + mutation.set_insert_or_update(self.mutation_write(table, columns, values)); + self.session + .borrow_mut() + .mutations + .get_or_insert_with(|| vec![]) + .push(mutation); + } + + fn mutation_write( + &self, + table: &str, + columns: &[&str], + values: Vec, + ) -> Mutation_Write { + let mut write = Mutation_Write::new(); + write.set_table(table.to_owned()); + write.set_columns(RepeatedField::from_vec( + columns.iter().map(|&column| column.to_owned()).collect(), + )); + write.set_values(RepeatedField::from_vec(values)); + write + } + fn in_write_transaction(&self) -> bool { self.session.borrow().in_write_transaction } @@ -352,6 +407,9 @@ impl SpannerDb { let mut req = CommitRequest::new(); req.set_session(spanner.session.get_name().to_owned()); req.set_transaction_id(transaction.get_id().to_vec()); + if let Some(mutations) = self.session.borrow_mut().mutations.take() { + req.set_mutations(RepeatedField::from_vec(mutations)); + } spanner.client.commit(&req)?; Ok(()) } else { @@ -975,7 +1033,106 @@ impl SpannerDb { } } + #[cfg(not(any(test, feature = "db_test")))] + pub fn put_bso_sync(&self, params: params::PutBso) -> Result { + let bsos = vec![params::PostCollectionBso { + id: params.id, + sortindex: params.sortindex, + payload: params.payload, + ttl: params.ttl, + }]; + let result = self.post_bsos_sync(params::PostBsos { + user_id: params.user_id, + collection: params.collection, + bsos, + failed: HashMap::new(), + })?; + Ok(result.modified) + } + + #[cfg(not(any(test, feature = "db_test")))] + pub fn post_bsos_sync(&self, params: params::PostBsos) -> Result { + let user_id = params.user_id; + let collection_id = self.get_or_create_collection_id(¶ms.collection)?; + // Ensure a parent record exists in user_collections before writing to + // bso (INTERLEAVE IN PARENT user_collections) + let timestamp = self.touch_collection(&user_id, collection_id)?; + + let mut sqlparams = params! { + "fxa_uid" => user_id.fxa_uid.clone(), + "fxa_kid" => user_id.fxa_kid.clone(), + "collection_id" => collection_id.to_string(), + }; + sqlparams.insert( + "ids".to_owned(), + as_list_value(params.bsos.iter().map(|pbso| pbso.id.clone())), + ); + let existing: Vec<_> = self + .sql( + "SELECT id + FROM bso + WHERE fxa_uid = @fxa_uid + AND fxa_kid = @fxa_kid + AND collection_id = @collection_id + AND id IN UNNEST(@ids)", + )? + .params(sqlparams) + .execute(&self.conn)? + .map(|row| row[0].get_string_value().to_owned()) + .collect(); + + let mut inserts = vec![]; + let mut updates = HashMap::new(); + let mut success = vec![]; + for bso in params.bsos { + success.push(bso.id.clone()); + if existing.contains(&bso.id) { + let (columns, values) = bso_to_update_row(&user_id, collection_id, bso, timestamp)?; + updates + .entry(columns) + .or_insert_with(|| vec![]) + .push(values); + } else { + let values = bso_to_insert_row(&user_id, collection_id, bso, timestamp)?; + inserts.push(values); + } + } + + if !inserts.is_empty() { + dbg!(&inserts); + self.insert( + "bso", + &[ + "fxa_uid", + "fxa_kid", + "collection_id", + "id", + "sortindex", + "payload", + "modified", + "expiry", + ], + inserts, + ); + } + for (columns, values) in updates { + dbg!(&columns, &values); + self.update("bso", &columns, values); + } + + let result = results::PostBsos { + modified: timestamp, + success, + failed: params.failed, + }; + Ok(result) + } + + // NOTE: Currently this put_bso_sync impl. is only used during db_tests, + // see above for the non-tests version + #[cfg(any(test, feature = "db_test"))] pub fn put_bso_sync(&self, bso: params::PutBso) -> Result { + use crate::db::util::to_rfc3339; let collection_id = self.get_or_create_collection_id(&bso.collection)?; let mut sqlparams = params! { "fxa_uid" => bso.user_id.fxa_uid.clone(), @@ -1106,7 +1263,7 @@ impl SpannerDb { let now_millis = timestamp.as_i64(); let ttl = bso .ttl - .map_or(DEFAULT_BSO_TTL, |ttl| ttl.try_into().unwrap()) + .map_or(i64::from(DEFAULT_BSO_TTL), |ttl| ttl.try_into().unwrap()) * 1000; let expirystring = to_rfc3339(now_millis + ttl)?; dbg!("!!!!! INSERT", &expirystring, timestamp, ttl); @@ -1125,6 +1282,9 @@ impl SpannerDb { Ok(touch) } + // NOTE: Currently this post_bso_sync impl. is only used during db_tests, + // see above for the non-tests version + #[cfg(any(test, feature = "db_test"))] pub fn post_bsos_sync(&self, input: params::PostBsos) -> Result { let collection_id = self.get_or_create_collection_id(&input.collection)?; let mut result = results::PostBsos { diff --git a/src/db/spanner/support.rs b/src/db/spanner/support.rs index e1b70690..2c7a4744 100644 --- a/src/db/spanner/support.rs +++ b/src/db/spanner/support.rs @@ -1,5 +1,7 @@ use std::collections::HashMap; +#[cfg(not(any(test, feature = "db_test")))] +use protobuf::well_known_types::NullValue; use protobuf::well_known_types::Struct; use protobuf::{ well_known_types::{ListValue, Value}, @@ -9,6 +11,12 @@ use protobuf::{ use super::models::{Conn, Result}; use crate::db::{results, util::SyncTimestamp, DbError, DbErrorKind}; +#[cfg(not(any(test, feature = "db_test")))] +use crate::{ + db::{params, spanner::models::DEFAULT_BSO_TTL, util::to_rfc3339}, + web::extractors::HawkIdentifier, +}; + use googleapis_raw::spanner::v1::type_pb::{Type, TypeCode}; type ParamValue = protobuf::well_known_types::Value; @@ -117,6 +125,7 @@ impl ExecuteSqlRequestBuilder { } } +#[derive(Debug)] pub struct SyncResultSet { result: ResultSet, } @@ -204,3 +213,74 @@ pub fn bso_from_row(row: Vec) -> Result { expiry: SyncTimestamp::from_rfc3339(&row[4].get_string_value())?.as_i64(), }) } + +#[cfg(not(any(test, feature = "db_test")))] +pub fn bso_to_insert_row( + user_id: &HawkIdentifier, + collection_id: i32, + bso: params::PostCollectionBso, + now: SyncTimestamp, +) -> Result { + let sortindex = bso + .sortindex + .map(|sortindex| as_value(sortindex.to_string())) + .unwrap_or_else(|| { + let mut value = Value::new(); + value.set_null_value(NullValue::NULL_VALUE); + value + }); + let ttl = bso.ttl.unwrap_or(DEFAULT_BSO_TTL); + let expiry = to_rfc3339(now.as_i64() + (i64::from(ttl) * 1000))?; + + let mut row = ListValue::new(); + row.set_values(RepeatedField::from_vec(vec![ + as_value(user_id.fxa_uid.clone()), + as_value(user_id.fxa_kid.clone()), + as_value(collection_id.to_string()), + as_value(bso.id), + sortindex, + as_value(bso.payload.unwrap_or_default()), + as_value(now.as_rfc3339()?), + as_value(expiry), + ])); + Ok(row) +} + +#[cfg(not(any(test, feature = "db_test")))] +pub fn bso_to_update_row( + user_id: &HawkIdentifier, + collection_id: i32, + bso: params::PostCollectionBso, + now: SyncTimestamp, +) -> Result<(Vec<&'static str>, ListValue)> { + let mut columns = vec!["fxa_uid", "fxa_kid", "collection_id", "id"]; + let mut values = vec![ + as_value(user_id.fxa_uid.clone()), + as_value(user_id.fxa_kid.clone()), + as_value(collection_id.to_string()), + as_value(bso.id), + ]; + + let modified = bso.payload.is_some() || bso.sortindex.is_some(); + if let Some(sortindex) = bso.sortindex { + columns.push("sortindex"); + values.push(as_value(sortindex.to_string())); + } + if let Some(payload) = bso.payload { + columns.push("payload"); + values.push(as_value(payload)); + } + if modified { + columns.push("modified"); + values.push(as_value(now.as_rfc3339()?)); + } + if let Some(ttl) = bso.ttl { + columns.push("expiry"); + let expiry = now.as_i64() + (i64::from(ttl) * 1000); + values.push(as_value(to_rfc3339(expiry)?)); + } + + let mut row = ListValue::new(); + row.set_values(RepeatedField::from_vec(values)); + Ok((columns, row)) +}