From 83209fd8191670026da62ed5a14c2e62a112572d Mon Sep 17 00:00:00 2001 From: Tarik Eshaq Date: Tue, 21 Jul 2020 11:35:18 -0700 Subject: [PATCH] [DO NOT MERGE] prototype to use a rust experiments api and expose it through glean --- .buildconfig.yml | 2 +- Cargo.lock | 831 +++++++++++++++++- Cargo.toml | 1 + build.gradle | 1 + glean-core/android/build.gradle | 32 + .../mozilla/telemetry/glean/Experiments.kt | 114 +++ .../mozilla/telemetry/glean/HttpConfig.kt | 150 ++++ .../telemetry/glean/rust/LibGleanFFI.kt | 22 +- .../telemetry/glean/rust/RustBuffer.kt | 34 +- .../mozilla/telemetry/glean/rust/RustError.kt | 61 ++ glean-core/ffi/Cargo.toml | 1 + glean-core/ffi/src/lib.rs | 4 + glean-core/nimbus-experiments/.gitignore | 12 + glean-core/nimbus-experiments/Cargo.toml | 34 + glean-core/nimbus-experiments/LICENSE | 373 ++++++++ glean-core/nimbus-experiments/README.md | 35 + glean-core/nimbus-experiments/build.rs | 7 + .../nimbus-experiments/examples/experiment.rs | 24 + glean-core/nimbus-experiments/src/buckets.rs | 69 ++ glean-core/nimbus-experiments/src/error.rs | 33 + .../nimbus-experiments/src/experiments.idl | 9 + .../src/experiments_msg_types.proto | 54 ++ glean-core/nimbus-experiments/src/ffi.rs | 69 ++ .../nimbus-experiments/src/http_client.rs | 85 ++ glean-core/nimbus-experiments/src/lib.rs | 148 ++++ glean-core/nimbus-experiments/src/matcher.rs | 51 ++ .../nimbus-experiments/src/persistence.rs | 65 ++ 27 files changed, 2309 insertions(+), 12 deletions(-) create mode 100644 glean-core/android/src/main/java/mozilla/telemetry/glean/Experiments.kt create mode 100644 glean-core/android/src/main/java/mozilla/telemetry/glean/HttpConfig.kt create mode 100644 glean-core/android/src/main/java/mozilla/telemetry/glean/rust/RustError.kt create mode 100644 glean-core/nimbus-experiments/.gitignore create mode 100644 glean-core/nimbus-experiments/Cargo.toml create mode 100644 glean-core/nimbus-experiments/LICENSE create mode 100644 glean-core/nimbus-experiments/README.md create mode 100644 glean-core/nimbus-experiments/build.rs create mode 100644 glean-core/nimbus-experiments/examples/experiment.rs create mode 100644 glean-core/nimbus-experiments/src/buckets.rs create mode 100644 glean-core/nimbus-experiments/src/error.rs create mode 100644 glean-core/nimbus-experiments/src/experiments.idl create mode 100644 glean-core/nimbus-experiments/src/experiments_msg_types.proto create mode 100644 glean-core/nimbus-experiments/src/ffi.rs create mode 100644 glean-core/nimbus-experiments/src/http_client.rs create mode 100644 glean-core/nimbus-experiments/src/lib.rs create mode 100644 glean-core/nimbus-experiments/src/matcher.rs create mode 100644 glean-core/nimbus-experiments/src/persistence.rs diff --git a/.buildconfig.yml b/.buildconfig.yml index 5266f988ac..c5584b93ed 100644 --- a/.buildconfig.yml +++ b/.buildconfig.yml @@ -1,4 +1,4 @@ -libraryVersion: 31.4.1 +libraryVersion: 31.4.1-TESTING29 groupId: org.mozilla.telemetry projects: glean: diff --git a/Cargo.lock b/Cargo.lock index 474aa1e8ea..2b830d9580 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -21,6 +21,11 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "anyhow" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "arrayref" version = "0.3.6" @@ -41,6 +46,11 @@ name = "autocfg" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "base64" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "benchmark" version = "0.1.0" @@ -85,6 +95,11 @@ name = "byteorder" version = "1.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bytes" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "c2-chacha" version = "0.2.3" @@ -132,6 +147,20 @@ dependencies = [ "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "crc32fast" version = "1.2.0" @@ -245,11 +274,24 @@ dependencies = [ "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "dtoa" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "either" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "encoding_rs" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "env_logger" version = "0.7.1" @@ -289,6 +331,11 @@ dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fixedbitset" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "flate2" version = "1.0.14" @@ -300,6 +347,83 @@ dependencies = [ "miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-channel" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-core" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-io" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-sink" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "futures-task" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "futures-util" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-io 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-task 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "getrandom" version = "0.1.14" @@ -322,7 +446,7 @@ dependencies = [ "flate2 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)", "iso8601 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "rkv 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", @@ -339,7 +463,8 @@ dependencies = [ "ffi-support 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "glean-core 31.4.1", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "nimbus_experiments 0.1.0", + "once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -352,11 +477,45 @@ dependencies = [ "glean-core 31.4.1", "jsonschema-valid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "h2" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hashbrown" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "heck" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "hermit-abi" version = "0.1.8" @@ -365,6 +524,30 @@ dependencies = [ "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "http" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "http-body" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "httparse" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "humantime" version = "1.3.0" @@ -373,6 +556,41 @@ dependencies = [ "quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "hyper" +version = "0.13.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "h2 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", + "socket2 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", + "want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "hyper-tls" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "idna" version = "0.2.0" @@ -383,6 +601,23 @@ dependencies = [ "unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "indexmap" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "hashbrown 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "iri-string" version = "0.3.0" @@ -445,6 +680,15 @@ dependencies = [ "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -507,6 +751,20 @@ dependencies = [ "rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "mime_guess" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "miniz_oxide" version = "0.3.6" @@ -515,6 +773,89 @@ dependencies = [ "adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "mio" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "net2 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "multimap" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "native-tls" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl 0.10.30 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.58 (registry+https://github.com/rust-lang/crates.io-index)", + "schannel 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "net2" +version = "0.2.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nimbus_experiments" +version = "0.1.0" +dependencies = [ + "anyhow 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", + "ffi-support 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "prost 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "prost-build 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "rkv 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "viaduct 0.1.0 (git+https://github.com/mozilla/application-services)", + "viaduct-reqwest 0.1.0 (git+https://github.com/mozilla/application-services)", +] + [[package]] name = "nom" version = "5.1.1" @@ -552,7 +893,7 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -560,6 +901,45 @@ name = "oorandom" version = "11.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "openssl" +version = "0.10.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-sys 0.9.58 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "openssl-probe" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "openssl-src" +version = "111.10.2+1.1.1g" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "openssl-sys" +version = "0.9.58" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", + "cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "openssl-src 111.10.2+1.1.1g (registry+https://github.com/rust-lang/crates.io-index)", + "pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)", + "vcpkg 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "ordered-float" version = "1.0.2" @@ -573,6 +953,43 @@ name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "petgraph" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "fixedbitset 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "indexmap 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pin-project" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "pin-project-internal 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "pin-project-lite" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "pkg-config" version = "0.3.17" @@ -602,6 +1019,53 @@ dependencies = [ "unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "prost" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "prost-derive 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "prost-build" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "multimap 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", + "petgraph 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "prost 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "prost-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "which 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "prost-derive" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "anyhow 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)", + "itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)", + "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "prost-types" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "prost 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "quick-error" version = "1.2.3" @@ -708,6 +1172,39 @@ dependencies = [ "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "reqwest" +version = "0.10.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "encoding_rs 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)", + "hyper-tls 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.36 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)", + "mime_guess 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen-futures 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.36 (registry+https://github.com/rust-lang/crates.io-index)", + "winreg 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "rkv" version = "0.10.3" @@ -748,11 +1245,41 @@ dependencies = [ "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "schannel" +version = "0.1.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "security-framework" +version = "0.4.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "security-framework-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "security-framework-sys" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "semver" version = "0.9.0" @@ -794,11 +1321,38 @@ dependencies = [ "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "itoa 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "smallvec" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "socket2" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "syn" version = "1.0.16" @@ -849,6 +1403,24 @@ dependencies = [ "unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "thiserror" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "thiserror-impl 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)", + "quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", + "syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "time" version = "0.1.42" @@ -868,6 +1440,81 @@ dependencies = [ "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "tokio" +version = "0.2.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)", + "mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)", + "num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "pin-project-lite 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", + "tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tower-service" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "tracing" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "tracing-core 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "tracing-core" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "try-lock" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "unicase" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "unicode-bidi" version = "0.3.4" @@ -884,6 +1531,11 @@ dependencies = [ "smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "unicode-segmentation" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unicode-width" version = "0.1.7" @@ -910,13 +1562,47 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "vcpkg" +version = "0.2.10" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "version_check" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "viaduct" +version = "0.1.0" +source = "git+https://github.com/mozilla/application-services#b849f86b8538033dfaa1d2d4b83036554f8c500b" +dependencies = [ + "ffi-support 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "prost 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "prost-derive 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", + "thiserror 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)", + "url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "viaduct-reqwest" +version = "0.1.0" +source = "git+https://github.com/mozilla/application-services#b849f86b8538033dfaa1d2d4b83036554f8c500b" +dependencies = [ + "ffi-support 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "reqwest 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)", + "viaduct 0.1.0 (git+https://github.com/mozilla/application-services)", +] + [[package]] name = "walkdir" version = "2.3.1" @@ -927,6 +1613,15 @@ dependencies = [ "winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", + "try-lock 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -938,6 +1633,8 @@ version = "0.2.59" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)", + "serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)", "wasm-bindgen-macro 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -955,6 +1652,17 @@ dependencies = [ "wasm-bindgen-shared 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", + "js-sys 0.3.36 (registry+https://github.com/rust-lang/crates.io-index)", + "wasm-bindgen 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", + "web-sys 0.3.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "wasm-bindgen-macro" version = "0.2.59" @@ -990,6 +1698,19 @@ dependencies = [ "wasm-bindgen 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "which" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi" version = "0.3.8" @@ -999,6 +1720,11 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -1017,24 +1743,46 @@ name = "winapi-x86_64-pc-windows-gnu" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "winreg" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [metadata] "checksum adler32 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" "checksum android_log-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "b8052e2d8aabbb8d556d6abbcce2a22b9590996c5f849b9c7ce4544a2e3b984e" "checksum android_logger 0.8.6 (registry+https://github.com/rust-lang/crates.io-index)" = "8cbd542dd180566fad88fd2729a53a62a734843c626638006a9d63ec0688484e" +"checksum anyhow 1.0.31 (registry+https://github.com/rust-lang/crates.io-index)" = "85bb70cc08ec97ca5450e6eba421deeea5f172c0fc61f78b5357b2a8e8be195f" "checksum arrayref 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" "checksum atty 0.2.14 (registry+https://github.com/rust-lang/crates.io-index)" = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" "checksum autocfg 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +"checksum base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" "checksum bincode 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf" "checksum bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" "checksum bstr 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "502ae1441a0a5adb8fbd38a5955a6416b9493e92b465de5e4a9bde6a539c2c48" "checksum bumpalo 3.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1f359dc14ff8911330a51ef78022d376f25ed00248912803b58f00cb1c27f742" "checksum byteorder 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" +"checksum bytes 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" "checksum c2-chacha 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "214238caa1bf3a496ec3392968969cab8549f96ff30652c9e56885329315f6bb" "checksum cast 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" "checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum chrono 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)" = "31850b4a4d6bae316f7a09e691c944c28299298837edc0a03f755618c23cbc01" "checksum clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5067f5bb2d80ef5d68b4c87db81601f0b75bca627bc2ef76b141d7b846a3c6d9" +"checksum core-foundation 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +"checksum core-foundation-sys 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" "checksum crc32fast 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" "checksum criterion 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1fc755679c12bda8e5523a71e4d654b6bf2e14bd838dfc48cde6559a05caf7d1" "checksum criterion-plot 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a01e15e0ea58e8234f96146b1f91fa9d0e4dd7a38da93ff7a75d42c0b9d3a545" @@ -1045,16 +1793,40 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum csv 1.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "00affe7f6ab566df61b4be3ce8cf16bc2576bca0963ceb0955e45d514bf9a279" "checksum csv-core 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "2b2466559f260f48ad25fe6317b3c8dac77b5bdb5763ac7d9d6103530663bc90" "checksum ctor 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "47c5e5ac752e18207b12e16b10631ae5f7f68f8805f335f9b817ead83d9ffce1" +"checksum dtoa 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "134951f4028bdadb9b84baf4232681efbf277da25144b9b0ad65df75946c422b" "checksum either 1.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +"checksum encoding_rs 0.8.23 (registry+https://github.com/rust-lang/crates.io-index)" = "e8ac63f94732332f44fe654443c46f6375d1939684c17b0afb6cb56b0456e171" "checksum env_logger 0.7.1 (registry+https://github.com/rust-lang/crates.io-index)" = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" "checksum failure 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f8273f13c977665c5db7eb2b99ae520952fe5ac831ae4cd09d80c4c7042b5ed9" "checksum failure_derive 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)" = "0bc225b78e0391e4b8683440bf2e63c2deeeb2ce5189eab46e2b68c6d3725d08" "checksum ffi-support 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "087be066eb6e85d7150f0c5400018a32802f99d688b2d3868c526f7bbfe17960" +"checksum fixedbitset 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "37ab347416e802de484e4d03c7316c48f1ecb56574dfd4a46a80f173ce1de04d" "checksum flate2 1.0.14 (registry+https://github.com/rust-lang/crates.io-index)" = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" +"checksum fnv 1.0.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +"checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +"checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" +"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" +"checksum futures-channel 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "f366ad74c28cca6ba456d95e6422883cfb4b252a83bed929c83abfdbbf2967d5" +"checksum futures-core 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "59f5fff90fd5d971f936ad674802482ba441b6f09ba5e15fd8b39145582ca399" +"checksum futures-io 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "de27142b013a8e869c14957e6d2edeef89e97c289e69d042ee3a49acd8b51789" +"checksum futures-sink 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "3f2032893cb734c7a05d85ce0cc8b8c4075278e93b24b66f9de99d6eb0fa8acc" +"checksum futures-task 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "bdb66b5f09e22019b1ab0830f7785bcea8e7a42148683f99214f73f8ec21a626" +"checksum futures-util 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "8764574ff08b701a084482c3c7031349104b07ac897393010494beaa18ce32c6" "checksum getrandom 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "7abc8dd8451921606d809ba32e95b6111925cd2906060d2dcc29c070220503eb" +"checksum h2 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "993f9e0baeed60001cf565546b0d3dbe6a6ad23f2bd31644a133c641eccf6d53" +"checksum hashbrown 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "34f595585f103464d8d2f6e9864682d74c1601fed5e07d62b1c9058dba8246fb" +"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205" "checksum hermit-abi 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1010591b26bbfe835e9faeabeb11866061cc7dcebffd56ad7d0942d0e61aefd8" +"checksum http 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" +"checksum http-body 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "13d5ff830006f7646652e057693569bfe0d51760c0085a071769d142a205111b" +"checksum httparse 1.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "cd179ae861f0c2e53da70d892f5f3029f9594be0c41dc5269cd371691b1dc2f9" "checksum humantime 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +"checksum hyper 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)" = "3e68a8dd9716185d9e64ea473ea6ef63529252e3e27623295a0378a19665d5eb" +"checksum hyper-tls 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "d979acc56dcb5b8dddba3917601745e877576475aa046df3226eabdecef78eed" "checksum idna 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "02e2673c30ee86b5b96a9cb52ad15718aa1f966f5ab9ad54a8b95d5ca33120a9" +"checksum indexmap 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5b88cd59ee5f71fea89a62248fc8f387d44400cefe05ef548466d61ced9029a7" +"checksum iovec 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" "checksum iri-string 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "402e5c3bd66bbe43ac90915097caa0347fc2666ecb8a0047154f4494ed577995" "checksum iso8601 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "cee08a007a59a8adfc96f69738ddf59e374888dfd84b49c4b916543067644d58" "checksum itertools 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f56a2d0bc861f9165be4eb3442afd3c236d8a98afd426f65d92324ae1091a484" @@ -1062,6 +1834,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum js-sys 0.3.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1cb931d43e71f560c81badb0191596562bafad2be06a3f9025b845c847c60df5" "checksum json-pointer 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8be58bc6b9e76616678217b983ab122d0ec207241c487ce450361ba7b5ddafd1" "checksum jsonschema-valid 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d6362170d8507a225c45f03991531bee7b87c54ce2c06c48fb2d3b11036667d8" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" "checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.71 (registry+https://github.com/rust-lang/crates.io-index)" = "9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49" "checksum lmdb-rkv 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "605061e5465304475be2041f19967a900175ea1b6d8f47fbab84a84fb8c48452" @@ -1071,19 +1844,39 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum maybe-uninit 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" "checksum memchr 2.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3728d817d99e5ac407411fa471ff9800a778d88a24685968b36824eaf4bee400" "checksum memoffset 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)" = "75189eb85871ea5c2e2c15abbdd541185f63b408415e5051f5cac122d8c774b9" +"checksum mime 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)" = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +"checksum mime_guess 2.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2684d4c2e97d99848d30b324b00c8fcc7e5c897b7cbb5819b09e7c90e8baf212" "checksum miniz_oxide 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" +"checksum mio 0.6.22 (registry+https://github.com/rust-lang/crates.io-index)" = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +"checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +"checksum multimap 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d8883adfde9756c1d30b0f519c9b8c502a94b41ac62f696453c37c7fc0a958ce" +"checksum native-tls 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "2b0d88c06fe90d5ee94048ba40409ef1d9315d86f6f38c2efdaad4fb50c58b2d" +"checksum net2 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)" = "2ba7c918ac76704fb42afcbbb43891e72731f3dcca3bef2a19786297baf14af7" "checksum nom 5.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0b471253da97532da4b61552249c521e01e736071f71c1a4f7ebbfbf0a06aad6" "checksum num-integer 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "3f6ea62e9d81a77cd3ee9a2a5b9b609447857f3d358704331e4ef39eb247fcba" "checksum num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "c62be47e61d1842b9170f0fdeec8eba98e60e90e5446449a0545e5152acd7096" "checksum num_cpus 1.12.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" -"checksum once_cell 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b1c601810575c99596d4afc46f78a678c80105117c379eb3650cf99b8a21ce5b" +"checksum once_cell 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0b631f7e854af39a1739f401cf34a8a013dfe09eac4fa4dba91e9768bd28168d" "checksum oorandom 11.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ebcec7c9c2a95cacc7cd0ecb89d8a8454eca13906f6deb55258ffff0adeb9405" +"checksum openssl 0.10.30 (registry+https://github.com/rust-lang/crates.io-index)" = "8d575eff3665419f9b83678ff2815858ad9d11567e082f5ac1814baba4e2bcb4" +"checksum openssl-probe 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "77af24da69f9d9341038eba93a073b1fdaaa1b788221b00a69bce9e762cb32de" +"checksum openssl-src 111.10.2+1.1.1g (registry+https://github.com/rust-lang/crates.io-index)" = "a287fdb22e32b5b60624d4a5a7a02dbe82777f730ec0dbc42a0554326fef5a70" +"checksum openssl-sys 0.9.58 (registry+https://github.com/rust-lang/crates.io-index)" = "a842db4709b604f0fe5d1170ae3565899be2ad3d9cbc72dedc789ac0511f78de" "checksum ordered-float 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "18869315e81473c951eb56ad5558bbc56978562d3ecfb87abb7a1e944cea4518" "checksum percent-encoding 2.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +"checksum petgraph 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "467d164a6de56270bd7c4d070df81d07beace25012d5103ced4e9ff08d6afdb7" +"checksum pin-project 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "12e3a6cdbfe94a5e4572812a0201f8c0ed98c1c452c7b8563ce2276988ef9c17" +"checksum pin-project-internal 0.4.22 (registry+https://github.com/rust-lang/crates.io-index)" = "6a0ffd45cf79d88737d7cc85bfd5d2894bee1139b356e616fe85dc389c61aaf7" +"checksum pin-project-lite 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "282adbf10f2698a7a77f8e983a74b2d18176c19a7fd32a45446139ae7b02b715" +"checksum pin-utils 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" "checksum pkg-config 0.3.17 (registry+https://github.com/rust-lang/crates.io-index)" = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" "checksum plotters 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)" = "4e3bb8da247d27ae212529352020f3e5ee16e83c0c258061d27b08ab92675eeb" "checksum ppv-lite86 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "74490b50b9fbe561ac330df47c08f3f33073d2d00c150f719147d7c54522fa1b" "checksum proc-macro2 1.0.9 (registry+https://github.com/rust-lang/crates.io-index)" = "6c09721c6781493a2a492a96b5a5bf19b65917fe6728884e7c44dd0c60ca3435" +"checksum prost 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ce49aefe0a6144a45de32927c77bd2859a5f7677b55f220ae5b744e87389c212" +"checksum prost-build 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "02b10678c913ecbd69350e8535c3aef91a8676c0773fc1d7b95cdd196d7f2f26" +"checksum prost-derive 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "537aa19b95acde10a12fec4301466386f757403de4cd4e5b4fa78fb5ecb18f72" +"checksum prost-types 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1834f67c0697c001304b75be76f67add9c89742eda3a085ad8ee0bb38c3417aa" "checksum quick-error 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum rand 0.7.3 (registry+https://github.com/rust-lang/crates.io-index)" = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" @@ -1097,40 +1890,68 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum regex-automata 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "92b73c2a1770c255c240eaa4ee600df1704a38dc3feaa6e949e7fcd4f8dc09f9" "checksum regex-syntax 0.6.16 (registry+https://github.com/rust-lang/crates.io-index)" = "1132f845907680735a84409c3bebc64d1364a5683ffbce899550cd09d5eaefc1" "checksum remove_dir_all 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "4a83fa3702a688b9359eccba92d153ac33fd2e8462f9e0e3fdf155239ea7792e" +"checksum reqwest 0.10.6 (registry+https://github.com/rust-lang/crates.io-index)" = "3b82c9238b305f26f53443e3a4bc8528d64b8d0bee408ec949eb7bf5635ec680" "checksum rkv 0.10.3 (registry+https://github.com/rust-lang/crates.io-index)" = "115984dd49e17333cb27c54e2a64dfd85246cfebe079065a3e37654ead93619e" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum ryu 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "bfa8506c1de11c9c4e4c38863ccbe02a305c8188e85a05a784c9e11e1c3910c8" "checksum same-file 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +"checksum schannel 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" "checksum scopeguard 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +"checksum security-framework 0.4.4 (registry+https://github.com/rust-lang/crates.io-index)" = "64808902d7d99f78eaddd2b4e2509713babc3dc3c85ad6f4c447680f3c01e535" +"checksum security-framework-sys 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "17bf11d99252f512695eb468de5516e5cf75455521e69dfe343f3b74e4748405" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" "checksum serde 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "414115f25f818d7dfccec8ee535d76949ae78584fc4f79a6f45a904bf8ab4449" "checksum serde_derive 1.0.104 (registry+https://github.com/rust-lang/crates.io-index)" = "128f9e303a5a29922045a830221b8f78ec74a5f544944f3d5984f8ec3895ef64" "checksum serde_json 1.0.48 (registry+https://github.com/rust-lang/crates.io-index)" = "9371ade75d4c2d6cb154141b9752cf3781ec9c05e0e5cf35060e1e70ee7b9c25" +"checksum serde_urlencoded 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" "checksum smallvec 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "5c2fb2ec9bcd216a5b0d0ccf31ab17b5ed1d627960edff65bbe95d3ce221cefc" +"checksum socket2 0.3.12 (registry+https://github.com/rust-lang/crates.io-index)" = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" "checksum syn 1.0.16 (registry+https://github.com/rust-lang/crates.io-index)" = "123bd9499cfb380418d509322d7a6d52e5315f064fe4b3ad18a53d6b92c07859" "checksum synstructure 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)" = "67656ea1dc1b41b1451851562ea232ec2e5a80242139f7e679ceccfb5d61f545" "checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9" "checksum termcolor 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" "checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +"checksum thiserror 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "7dfdd070ccd8ccb78f4ad66bf1982dc37f620ef696c6b5028fe2ed83dd3d0d08" +"checksum thiserror-impl 1.0.20 (registry+https://github.com/rust-lang/crates.io-index)" = "bd80fc12f73063ac132ac92aceea36734f04a1d93c1240c6944e23a3b8841793" "checksum time 0.1.42 (registry+https://github.com/rust-lang/crates.io-index)" = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" "checksum tinytemplate 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a" +"checksum tokio 0.2.22 (registry+https://github.com/rust-lang/crates.io-index)" = "5d34ca54d84bf2b5b4d7d31e901a8464f7b60ac145a284fba25ceb801f2ddccd" +"checksum tokio-tls 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9a70f4fcd7b3b24fb194f837560168208f669ca8cb70d0c4b862944452396343" +"checksum tokio-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +"checksum tower-service 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e987b6bf443f4b5b3b6f38704195592cca41c5bb7aedd3c3693c7081f8289860" +"checksum tracing 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "dbdf4ccd1652592b01286a5dbe1e2a77d78afaa34beadd9872a5f7396f92aaa9" +"checksum tracing-core 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "94ae75f0d28ae10786f3b1895c55fe72e79928fd5ccdebb5438c75e93fec178f" +"checksum try-lock 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" +"checksum unicase 2.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "50f37be617794602aabbeee0be4f259dc1778fabe05e2d67ee8f79326d5cb4f6" "checksum unicode-bidi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "49f2bd0c6468a8230e1db229cff8029217cf623c767ea5d60bfbd42729ea54d5" "checksum unicode-normalization 0.1.12 (registry+https://github.com/rust-lang/crates.io-index)" = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" +"checksum unicode-segmentation 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0" "checksum unicode-width 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "caaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum url 2.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" "checksum uuid 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fde2f6a4bea1d6e007c4ad38c6839fa71cbb63b6dbf5b595aa38dc9b1093c11" +"checksum vcpkg 0.2.10 (registry+https://github.com/rust-lang/crates.io-index)" = "6454029bf181f092ad1b853286f23e2c507d8e8194d01d92da4a55c274a5508c" "checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" +"checksum viaduct 0.1.0 (git+https://github.com/mozilla/application-services)" = "" +"checksum viaduct-reqwest 0.1.0 (git+https://github.com/mozilla/application-services)" = "" "checksum walkdir 2.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +"checksum want 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" "checksum wasi 0.9.0+wasi-snapshot-preview1 (registry+https://github.com/rust-lang/crates.io-index)" = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" "checksum wasm-bindgen 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "3557c397ab5a8e347d434782bcd31fc1483d927a6826804cec05cc792ee2519d" "checksum wasm-bindgen-backend 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "e0da9c9a19850d3af6df1cb9574970b566d617ecfaf36eb0b706b6f3ef9bd2f8" +"checksum wasm-bindgen-futures 0.4.9 (registry+https://github.com/rust-lang/crates.io-index)" = "457414a91863c0ec00090dba537f88ab955d93ca6555862c29b6d860990b8a8a" "checksum wasm-bindgen-macro 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "0f6fde1d36e75a714b5fe0cffbb78978f222ea6baebb726af13c78869fdb4205" "checksum wasm-bindgen-macro-support 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "25bda4168030a6412ea8a047e27238cadf56f0e53516e1e83fec0a8b7c786f6d" "checksum wasm-bindgen-shared 0.2.59 (registry+https://github.com/rust-lang/crates.io-index)" = "fc9f36ad51f25b0219a3d4d13b90eb44cd075dff8b6280cca015775d7acaddd8" "checksum web-sys 0.3.36 (registry+https://github.com/rust-lang/crates.io-index)" = "721c6263e2c66fd44501cc5efbfa2b7dfa775d13e4ea38c46299646ed1f9c70a" +"checksum which 3.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "8093091eeb260906a183e6ae1abdba2ef5ef2257a21801128899c3fc699229c6" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" "checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" "checksum winapi-util 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4ccfbf554c6ad11084fb7517daca16cfdcaccbdadba4fc336f032a8b12c2ad80" "checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +"checksum winreg 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +"checksum ws2_32-sys 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" diff --git a/Cargo.toml b/Cargo.toml index 4fc37f8e1a..9d5b6456ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,6 +5,7 @@ members = [ "glean-core/ffi", "glean-core/preview", "glean-core/benchmark", + "glean-core/nimbus-experiments", ] [profile.release] diff --git a/build.gradle b/build.gradle index ccea46a989..9a1ee5e2f9 100644 --- a/build.gradle +++ b/build.gradle @@ -66,6 +66,7 @@ buildscript { // Docs generation classpath "org.jetbrains.dokka:dokka-android-gradle-plugin:$versions.dokka" + classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.12' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } diff --git a/glean-core/android/build.gradle b/glean-core/android/build.gradle index c271903add..11c3c0560a 100644 --- a/glean-core/android/build.gradle +++ b/glean-core/android/build.gradle @@ -17,6 +17,7 @@ apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'org.jetbrains.dokka-android' apply plugin: 'jacoco' +apply plugin: 'com.google.protobuf' /* * This defines the location of the JSON schema used to validate the pings @@ -65,6 +66,13 @@ android { } sourceSets { + // We define where the gradle tasks can find + // the .proto file used in the generation + main { + proto { + srcDir '../nimbus-experiments/src' + } + } main.jniLibs.srcDirs += "$buildDir/nativeLibs/android" test.resources.srcDirs += "$buildDir/rustJniLibs/desktop" test.resources.srcDirs += "$buildDir/nativeLibs/desktop" @@ -172,13 +180,37 @@ configurations { jnaForTest } +// We generate a bunch of gradle tasks that will help us +// generate the kotlin files associated with the .proto file +protobuf { + protoc { + artifact = 'com.google.protobuf:protoc:3.11.4' + } + plugins { + javalite { + artifact = 'com.google.protobuf:protoc-gen-javalite:3.0.0' + } + } + generateProtoTasks { + all().each { task -> + task.builtins { + java { + option "lite" + } + } + } + } +} + dependencies { + api "org.mozilla.components:concept-fetch:$versions.android_components" jnaForTest "net.java.dev.jna:jna:$versions.jna@jar" implementation "net.java.dev.jna:jna:$versions.jna@aar" // Note: the following version must be kept in sync implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$versions.kotlin" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$versions.coroutines" + implementation 'com.google.protobuf:protobuf-javalite:3.11.4' implementation "androidx.annotation:annotation:$versions.androidx_annotation" implementation "androidx.lifecycle:lifecycle-extensions:$versions.androidx_lifecycle_extensions" diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/Experiments.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/Experiments.kt new file mode 100644 index 0000000000..44e2278ab9 --- /dev/null +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/Experiments.kt @@ -0,0 +1,114 @@ +package mozilla.telemetry.glean + +import android.content.Context +import android.os.Build +import com.sun.jna.Pointer +import mozilla.telemetry.glean.rust.LibGleanFFI +import mozilla.telemetry.glean.rust.RustError +import java.util.* +import java.util.concurrent.atomic.AtomicLong +import com.google.protobuf.CodedOutputStream +import com.google.protobuf.MessageLite +import com.sun.jna.Native +import java.nio.ByteBuffer +import java.nio.ByteOrder + +// A LOT OF THIS IS COPIED FOR THE SAKE OF THE PROTOTYPE, NOT COMPLETE +fun T.toNioDirectBuffer(): Pair { + val len = this.serializedSize + val nioBuf = ByteBuffer.allocateDirect(len) + nioBuf.order(ByteOrder.nativeOrder()) + val output = CodedOutputStream.newInstance(nioBuf) + this.writeTo(output) + output.checkNoSpaceLeft() + return Pair(first = nioBuf, second = len) +} + +open class ExperimentsInternalAPI internal constructor () { + private var raw: AtomicLong = AtomicLong(0) + + fun initialize( + applicationContext: Context, + dbPath: String + ) { + val appCtx = MsgTypes.AppContext.newBuilder() + .setAppId(applicationContext.packageName) + .setAppVersion(applicationContext.packageManager.getPackageInfo(applicationContext.packageName, 0).versionName) + .setDeviceManufacturer(Build.MANUFACTURER) + .setLocaleCountry( + try { + Locale.getDefault().isO3Country + } catch (e: MissingResourceException) { + Locale.getDefault().country + } + ) + .setLocaleLanguage( + try { + Locale.getDefault().isO3Language + } catch (e: MissingResourceException) { + Locale.getDefault().language + } + ) + .setDeviceModel(Build.DEVICE) + .build() + val (nioBuf, len) = appCtx.toNioDirectBuffer() + raw.set( rustCall { error -> + val ptr = Native.getDirectBufferPointer(nioBuf) + LibGleanFFI.INSTANCE.experiments_new(ptr, len, dbPath, error) + }) + } + + fun getBranch(experimentName: String): String { + var ptr = rustCall { error -> + LibGleanFFI.INSTANCE.experiments_get_branch(raw.get(), experimentName, error) + } + return ptr.getAndConsumeRustString() + } + + /** + * Helper to read a null terminated String out of the Pointer and free it. + * + * Important: Do not use this pointer after this! For anything! + */ + internal fun Pointer.getAndConsumeRustString(): String { + return this.getRustString() + // PLEASE INSERT A FREE HERE!!!!!!! + } + + /** + * Helper to read a null terminated string out of the pointer. + * + * Important: doesn't free the pointer, use [getAndConsumeRustString] for that! + */ + internal fun Pointer.getRustString(): String { + return this.getString(0, "utf8") + } + + // In practice we usually need to be synchronized to call this safely, so it doesn't + // synchronize itself + private inline fun nullableRustCall(callback: (RustError.ByReference) -> U?): U? { + val e = RustError.ByReference() + try { + val ret = callback(e) + if (e.isFailure()) { + // We ignore it for now, although we shouldn't just cuz protoype + //throw e.intoException() + } + return ret + } finally { + // This only matters if `callback` throws (or does a non-local return, which + // we currently don't do) + e.ensureConsumed() + } + } + + private inline fun rustCall(callback: (RustError.ByReference) -> U?): U { + return nullableRustCall(callback)!! + } +} + +/** + * The main experiments object + * ``` + */ +object Experiments : ExperimentsInternalAPI() \ No newline at end of file diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/HttpConfig.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/HttpConfig.kt new file mode 100644 index 0000000000..f80d6a01c2 --- /dev/null +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/HttpConfig.kt @@ -0,0 +1,150 @@ +package mozilla.telemetry.glean + +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// THIS IS A CLONE OF THE OTHER HTTPCONFIG USED FOR APPLICATION SERVICES +// SEEMED CONVIENIENT FOR THE SAKE OF THE PROTOTYPE, PREFERRABLY +// WE CAN USE THE SAME HTTPCONFIG, BUT I COULDN'T WRAP MY HEAD ON A QUICK +// WAY TO DO THAT FOR A PROTOTYPE + +import com.google.protobuf.ByteString +import mozilla.components.concept.fetch.Client +import mozilla.components.concept.fetch.MutableHeaders +import mozilla.components.concept.fetch.Request +import mozilla.telemetry.glean.rust.LibGleanFFI +import mozilla.telemetry.glean.rust.RawFetchCallback +import mozilla.telemetry.glean.rust.RustBuffer +import java.util.concurrent.TimeUnit +import java.util.concurrent.locks.ReentrantReadWriteLock +import kotlin.concurrent.read +import kotlin.concurrent.write + +/** + * Singleton allowing management of the HTTP backend + * used by Rust components. + */ +object RustHttpConfig { + // Protects imp/client + private var lock = ReentrantReadWriteLock() + @Volatile + private var client: Lazy? = null + // Important note to future maintainers: if you mess around with + // this code, you have to make sure `imp` can't get GCed. Extremely + // bad things will happen if it does! + @Volatile + private var imp: CallbackImpl? = null + + /** + * Set the HTTP client to be used by all Rust code. + * the `Lazy`'s value is not read until the first request is made. + */ + @Synchronized + fun setClient(c: Lazy) { + lock.write { + client = c + if (imp == null) { + imp = CallbackImpl() + LibGleanFFI.INSTANCE.viaduct_initialize(imp!!) + } + } + } + + internal fun convertRequest(request: MsgTypes.Request): Request { + val headers = MutableHeaders() + for (h in request.headersMap) { + headers.append(h.key, h.value) + } + return Request( + url = request.url, + method = convertMethod(request.method), + headers = headers, + connectTimeout = Pair(request.connectTimeoutSecs.toLong(), TimeUnit.SECONDS), + readTimeout = Pair(request.readTimeoutSecs.toLong(), TimeUnit.SECONDS), + body = if (request.hasBody()) { + Request.Body(request.body.newInput()) + } else { + null + }, + redirect = if (request.followRedirects) { + Request.Redirect.FOLLOW + } else { + Request.Redirect.MANUAL + }, + cookiePolicy = Request.CookiePolicy.OMIT, + useCaches = request.useCaches + ) + } + + @Suppress("TooGenericExceptionCaught", "ReturnCount") + internal fun doFetch(b: RustBuffer.ByValue): RustBuffer.ByValue { + lock.read { + try { + val request = MsgTypes.Request.parseFrom(b.asCodedInputStream()) + val rb = try { + // Note: `client!!` is fine here, since if client is null, + // we wouldn't have yet initialized + val resp = client!!.value.fetch(convertRequest(request)) + val rb = MsgTypes.Response.newBuilder() + .setUrl(resp.url) + .setStatus(resp.status) + .setBody(resp.body.useStream { + ByteString.readFrom(it) + }) + + for (h in resp.headers) { + rb.putHeaders(h.name, h.value) + } + rb + } catch (e: Throwable) { + MsgTypes.Response.newBuilder().setExceptionMessage("fetch error: ${e.message ?: e.javaClass.canonicalName}") + } + val built = rb.build() + val needed = built.serializedSize + val outputBuf = LibGleanFFI.INSTANCE.viaduct_alloc_bytebuffer(needed) + try { + // This is only null if we passed a negative number or something to + // viaduct_alloc_bytebuffer. + val stream = outputBuf.asCodedOutputStream()!! + built.writeTo(stream) + return outputBuf + } catch (e: Throwable) { + // Note: we want to clean this up only if we are not returning it to rust. + LibGleanFFI.INSTANCE.viaduct_destroy_bytebuffer(outputBuf) + LibGleanFFI.INSTANCE.viaduct_log_error("Failed to write buffer: ${e.message}") + throw e + } + } finally { + LibGleanFFI.INSTANCE.viaduct_destroy_bytebuffer(b) + } + } + } +} + +internal fun convertMethod(m: MsgTypes.Request.Method): Request.Method { + return when (m) { + MsgTypes.Request.Method.GET -> Request.Method.GET + MsgTypes.Request.Method.POST -> Request.Method.POST + MsgTypes.Request.Method.HEAD -> Request.Method.HEAD + MsgTypes.Request.Method.OPTIONS -> Request.Method.OPTIONS + MsgTypes.Request.Method.DELETE -> Request.Method.DELETE + MsgTypes.Request.Method.PUT -> Request.Method.PUT + MsgTypes.Request.Method.TRACE -> Request.Method.TRACE + MsgTypes.Request.Method.CONNECT -> Request.Method.CONNECT + } +} + +internal class CallbackImpl : RawFetchCallback { + @Suppress("TooGenericExceptionCaught") + override fun invoke(b: RustBuffer.ByValue): RustBuffer.ByValue { + try { + return RustHttpConfig.doFetch(b) + } catch (e: Throwable) { + LibGleanFFI.INSTANCE.viaduct_log_error("doFetch failed: ${e.message}") + // This is our last resort. It's bad news should we fail to + // return something from this function. + return RustBuffer.ByValue() + } + } +} diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/LibGleanFFI.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/LibGleanFFI.kt index f232506c48..f5832ad4a3 100644 --- a/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/LibGleanFFI.kt +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/LibGleanFFI.kt @@ -6,10 +6,7 @@ package mozilla.telemetry.glean.rust -import com.sun.jna.Library -import com.sun.jna.Native -import com.sun.jna.Pointer -import com.sun.jna.StringArray +import com.sun.jna.* import java.lang.reflect.Proxy import mozilla.telemetry.glean.config.FfiConfiguration import mozilla.telemetry.glean.net.FfiPingUploadTask @@ -605,4 +602,21 @@ internal interface LibGleanFFI : Library { // Misc fun glean_str_free(ptr: Pointer) + + // DO NOT MERGE ME PLEASE. THIS WAS ONLY ADDED FOR PROTOTYPING PURPOSES!!! + fun experiments_new(appContext: Pointer, appContextLen: Int, dbPath: String, error: RustError.ByReference): Long + + fun experiments_get_branch(handle: Long, branchName: String, error: RustError.ByReference): Pointer? + + fun viaduct_destroy_bytebuffer(b: RustBuffer.ByValue) + // Returns null buffer to indicate failure + fun viaduct_alloc_bytebuffer(sz: Int): RustBuffer.ByValue + // Returns 0 to indicate redundant init. + fun viaduct_initialize(cb: RawFetchCallback): Byte + + fun viaduct_log_error(s: String) +} + +internal interface RawFetchCallback: Callback { + fun invoke(b: RustBuffer.ByValue): RustBuffer.ByValue } diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/RustBuffer.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/RustBuffer.kt index 376cfb8978..0380f1dde5 100644 --- a/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/RustBuffer.kt +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/RustBuffer.kt @@ -4,8 +4,12 @@ package mozilla.telemetry.glean.rust +import com.google.protobuf.CodedInputStream +import com.google.protobuf.CodedOutputStream import com.sun.jna.Pointer import com.sun.jna.Structure +import java.nio.ByteBuffer + /** * This is a mapping for the `glean_core::byte_buffer::ByteBuffer` struct. @@ -42,12 +46,38 @@ import com.sun.jna.Structure */ @Structure.FieldOrder("len", "data") open class RustBuffer : Structure() { - @JvmField var len: Int = 0 + @JvmField var len: Long = 0 @JvmField var data: Pointer? = null fun getByteArray(): ByteArray { - return this.data!!.getByteArray(0, this.len) + return this.data!!.getByteArray(0, this.len.toInt()) + } + + @Suppress("TooGenericExceptionThrown") + fun asCodedInputStream(): CodedInputStream? { + return this.data?.let { + // We use a ByteArray instead of a ByteBuffer to avoid triggering the following code path: + // https://github.com/protocolbuffers/protobuf/blob/e667bf6eaaa2fb1ba2987c6538df81f88500d030/java/core/src/main/java/com/google/protobuf/CodedInputStream.java#L185-L187 + // Bug: https://github.com/protocolbuffers/protobuf/issues/7422 + if (this.len < Int.MIN_VALUE || this.len > Int.MAX_VALUE) { + throw RuntimeException("len does not fit in a int") + } + CodedInputStream.newInstance(it.getByteArray(0, this.len.toInt())) + } + } + + fun asCodedOutputStream(): CodedOutputStream? { + return this.data?.let { + // We use newSafeInstance through reflection to avoid triggering the following code path: + // https://github.com/protocolbuffers/protobuf/blob/e667bf6eaaa2fb1ba2987c6538df81f88500d030/java/core/src/main/java/com/google/protobuf/CodedOutputStream.java#L134-L136 + // Bug: https://github.com/protocolbuffers/protobuf/issues/7422 + val method = CodedOutputStream::class.java.getDeclaredMethod("newSafeInstance", ByteBuffer::class.java) + method.isAccessible = true + return method.invoke(null, it.getByteBuffer(0, this.len)) as CodedOutputStream + } } class ByValue : RustBuffer(), Structure.ByValue + + class ByReference: RustBuffer(), Structure.ByReference } diff --git a/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/RustError.kt b/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/RustError.kt new file mode 100644 index 0000000000..f0e39a0886 --- /dev/null +++ b/glean-core/android/src/main/java/mozilla/telemetry/glean/rust/RustError.kt @@ -0,0 +1,61 @@ +package mozilla.telemetry.glean.rust + +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +import com.sun.jna.Pointer +import com.sun.jna.Structure + +/** + * This should be considered private, but it needs to be public for JNA. + */ +@Structure.FieldOrder("code", "message") +open class RustError : Structure() { + + class ByReference : RustError(), Structure.ByReference + + @JvmField var code: Int = 0 + @JvmField var message: Pointer? = null + + /** + * Does this represent failure? + */ + fun isFailure(): Boolean { + return code != 0 + } + + @Suppress("ReturnCount", "TooGenericExceptionThrown", "ComplexMethod") + fun intoException(): Exception { + // It's probably a bad idea to throw here! We're probably leaking something if this is + // ever hit! (But we shouldn't ever hit it?) + throw RuntimeException("[Bug] intoException called on non-failure!") + } + + /** + * Get and consume the error message, or null if there is none. + */ + @Synchronized + fun consumeErrorMessage(): String { + val result = this.message?.getAndConsumeRustString() + this.message = null + if (result == null) { + throw NullPointerException("consumeErrorMessage called with null message!") + } + return result + } + + @Synchronized + fun ensureConsumed() { + this.message?.getAndConsumeRustString() + this.message = null + } + + /** + * Get the error message or null if there is none. + */ + fun getMessage(): String? { + return this.message?.getRustString() + } +} diff --git a/glean-core/ffi/Cargo.toml b/glean-core/ffi/Cargo.toml index 7e156db9da..94a4dfd56b 100644 --- a/glean-core/ffi/Cargo.toml +++ b/glean-core/ffi/Cargo.toml @@ -32,6 +32,7 @@ log = "0.4.8" serde_json = "1.0.44" uuid = { version = "0.8.1", features = ["v4"] } once_cell = "1.2.0" +nimbus_experiments = { path = "../nimbus-experiments"} [dependencies.glean-core] path = ".." diff --git a/glean-core/ffi/src/lib.rs b/glean-core/ffi/src/lib.rs index 499e973a7c..eb77b5648f 100644 --- a/glean-core/ffi/src/lib.rs +++ b/glean-core/ffi/src/lib.rs @@ -44,6 +44,10 @@ use handlemap_ext::HandleMapExtension; use ping_type::PING_TYPES; use upload::FfiPingUploadTask; +// DO NOT MERGE! +// We don't need this since they are pulled anyways, but just to be explicit for the prototype! +pub use nimbus_experiments::ffi::{experiements_destroy, experiments_get_branch, experiments_new}; +pub use nimbus_experiments::viaduct::*; /// Execute the callback with a reference to the Glean singleton, returning a `Result`. /// /// The callback returns a `Result` while: diff --git a/glean-core/nimbus-experiments/.gitignore b/glean-core/nimbus-experiments/.gitignore new file mode 100644 index 0000000000..3a679937ba --- /dev/null +++ b/glean-core/nimbus-experiments/.gitignore @@ -0,0 +1,12 @@ +# Generated by Cargo +# will have compiled files and executables +/target/ + +/ffi/target + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk diff --git a/glean-core/nimbus-experiments/Cargo.toml b/glean-core/nimbus-experiments/Cargo.toml new file mode 100644 index 0000000000..267825affc --- /dev/null +++ b/glean-core/nimbus-experiments/Cargo.toml @@ -0,0 +1,34 @@ +[package] +name = "nimbus_experiments" +version = "0.1.0" +authors = ["Tarik Eshaq "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +url = "2.1" +serde = { version = "1", features = ["rc"] } +serde_derive = "1" +serde_json = "1" +anyhow = "1.0" +rand = "0.7" +log = "0.4" +viaduct = { git = "https://github.com/mozilla/application-services" } +ffi-support = "0.4" +thiserror = "1" +rkv = "0.10" +lazy_static = "1.4" +uuid = { version = "0.8", features = ["serde", "v4"]} +prost = "0.6" + +[build-dependencies] +prost-build = { version = "0.6" } + +[lib] +name = "nimbus_experiments" +crate-type = ["lib"] + +[dev-dependencies] +viaduct-reqwest = { git = "https://github.com/mozilla/application-services" } + diff --git a/glean-core/nimbus-experiments/LICENSE b/glean-core/nimbus-experiments/LICENSE new file mode 100644 index 0000000000..a612ad9813 --- /dev/null +++ b/glean-core/nimbus-experiments/LICENSE @@ -0,0 +1,373 @@ +Mozilla Public License Version 2.0 +================================== + +1. Definitions +-------------- + +1.1. "Contributor" + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +1.2. "Contributor Version" + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +1.3. "Contribution" + means Covered Software of a particular Contributor. + +1.4. "Covered Software" + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +1.5. "Incompatible With Secondary Licenses" + means + + (a) that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or + + (b) that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +1.6. "Executable Form" + means any form of the work other than Source Code Form. + +1.7. "Larger Work" + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +1.8. "License" + means this document. + +1.9. "Licensable" + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +1.10. "Modifications" + means any of the following: + + (a) any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or + + (b) any new file in Source Code Form that contains any Covered + Software. + +1.11. "Patent Claims" of a Contributor + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +1.12. "Secondary License" + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +1.13. "Source Code Form" + means the form of the work preferred for making modifications. + +1.14. "You" (or "Your") + means an individual or a legal entity exercising rights under this + License. For legal entities, "You" includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, "control" means (a) the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or (b) ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + +2. License Grants and Conditions +-------------------------------- + +2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +(a) under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and + +(b) under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +(a) for any code that a Contributor has removed from Covered Software; + or + +(b) for infringements caused by: (i) Your and any other third party's + modifications of Covered Software, or (ii) the combination of its + Contributions with other software (except as part of its Contributor + Version); or + +(c) under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + +3. Responsibilities +------------------- + +3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +(a) such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +(b) You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + +4. Inability to Comply Due to Statute or Regulation +--------------------------------------------------- + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: (a) comply with +the terms of this License to the maximum extent possible; and (b) +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + +5. Termination +-------------- + +5.1. The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated (a) provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and (b) on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +5.2. If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +5.3. In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + +************************************************************************ +* * +* 6. Disclaimer of Warranty * +* ------------------------- * +* * +* Covered Software is provided under this License on an "as is" * +* basis, without warranty of any kind, either expressed, implied, or * +* statutory, including, without limitation, warranties that the * +* Covered Software is free of defects, merchantable, fit for a * +* particular purpose or non-infringing. The entire risk as to the * +* quality and performance of the Covered Software is with You. * +* Should any Covered Software prove defective in any respect, You * +* (not any Contributor) assume the cost of any necessary servicing, * +* repair, or correction. This disclaimer of warranty constitutes an * +* essential part of this License. No use of any Covered Software is * +* authorized under this License except under this disclaimer. * +* * +************************************************************************ + +************************************************************************ +* * +* 7. Limitation of Liability * +* -------------------------- * +* * +* Under no circumstances and under no legal theory, whether tort * +* (including negligence), contract, or otherwise, shall any * +* Contributor, or anyone who distributes Covered Software as * +* permitted above, be liable to You for any direct, indirect, * +* special, incidental, or consequential damages of any character * +* including, without limitation, damages for lost profits, loss of * +* goodwill, work stoppage, computer failure or malfunction, or any * +* and all other commercial damages or losses, even if such party * +* shall have been informed of the possibility of such damages. This * +* limitation of liability shall not apply to liability for death or * +* personal injury resulting from such party's negligence to the * +* extent applicable law prohibits such limitation. Some * +* jurisdictions do not allow the exclusion or limitation of * +* incidental or consequential damages, so this exclusion and * +* limitation may not apply to You. * +* * +************************************************************************ + +8. Litigation +------------- + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + +9. Miscellaneous +---------------- + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + +10. Versions of the License +--------------------------- + +10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +10.4. Distributing Source Code Form that is Incompatible With Secondary +Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +Exhibit A - Source Code Form License Notice +------------------------------------------- + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +Exhibit B - "Incompatible With Secondary Licenses" Notice +--------------------------------------------------------- + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/glean-core/nimbus-experiments/README.md b/glean-core/nimbus-experiments/README.md new file mode 100644 index 0000000000..cda327abe8 --- /dev/null +++ b/glean-core/nimbus-experiments/README.md @@ -0,0 +1,35 @@ +# Nimbus Experimenter + +## What is this +As a part of preperation for the Rust Nimbus SDK, this was built as a small prototype to uncover any issues or any unexpected blockers. +This README will serve as a document explaining what we learned, how you can test this, what is missing and what we would might need to think hard about. + + +### Code organization +So far, the `nimbus-experiments` crate lives inside the `glean-core` crate. This is not where we expect the actual SDK to live, but it was convienient for prototyping other aspects of the project. The is current dicussion on where the actual crate will live, but for now this seemed like a quick spot for it us to try it out. + +The crate is broken down to a few modules, each has a small descripton on top describing what it is for, and a few `TODO`s explaining what still needs to be done. The most notable one is the `ffi` which defines simple `C` apis, that later get re-exported in `glean-core/ffi` + +The Android side of this crate is implemented in `glean-core/android` it was quicker to leverage the already setup infra for glean for the prototype, although, the full implementation will want to expose it's own bindings. + +## How can I try it out? +This PR adds all the `mavenLocal` needed to publish glean locally, which you can then use in `Android Components` to run a quick test to see the flow working. +Follow the following steps: +1. Make sure you are on the `test-experiments-do-not-merge` branch of [this](https://github.com/a-s-dev/glean) fork of glean: + + run `git clone git@github.com:a-s-dev/glean.git && cd glean` + + Then `git checkout test-experiments-do-not-merge` +2. Run `./gradlew publishToMavenLocal` in the root directory of **glean** +3. Checkout [this](https://github.com/a-s-dev/android-components) fork of `Android Components`: + + run `git clone git@github.com:a-s-dev/android-components.git` + + Then `git checkout test-experiments-do-not-merge` +4. In the `samples-glean` application in Android Components, open [`GleanApplication.kt`](https://github.com/a-s-dev/android-components/blob/test-experiments-do-not-merge/samples/glean/src/main/java/org/mozilla/samples/glean/GleanApplication.kt) and set a break point [here](https://github.com/a-s-dev/android-components/blob/test-experiments-do-not-merge/samples/glean/src/main/java/org/mozilla/samples/glean/GleanApplication.kt#L49) + +## So what did you really learn? +1. We'll need to think a bit about networking. The prototype uses `viaduct` that allows the Kotlin consumer to set the `HttpClient` This works okay, except we end up duplicating the `HttpConfig` on the `Android Components` side. This is due to one `HttpConfig` setting the `viaduct` backend of the `Application Services` megazord, and one for our binary. +2. Having this as it's own repo would only work if we have a clean way to interact with `glean` +3. `rkv` worked really well for persistence. +4. We used `protobufs` in the prototype for the more complex data, the `glean-core` crate uses struct pointers, we'll need to discuss what the best way to pass in complex data is. diff --git a/glean-core/nimbus-experiments/build.rs b/glean-core/nimbus-experiments/build.rs new file mode 100644 index 0000000000..bd19228497 --- /dev/null +++ b/glean-core/nimbus-experiments/build.rs @@ -0,0 +1,7 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +fn main() { + prost_build::compile_protos(&["src/experiments_msg_types.proto"], &["src/"]).unwrap(); +} diff --git a/glean-core/nimbus-experiments/examples/experiment.rs b/glean-core/nimbus-experiments/examples/experiment.rs new file mode 100644 index 0000000000..093709899b --- /dev/null +++ b/glean-core/nimbus-experiments/examples/experiment.rs @@ -0,0 +1,24 @@ +use anyhow::Result; +use nimbus_experiments::{AppContext, Experiments}; +fn main() -> Result<()> { + viaduct_reqwest::use_reqwest_backend(); + let exp = Experiments::new(AppContext::default(), "./mydb"); + let enrolled_exp = exp.get_enrolled_experiments(); + exp.get_experiments().iter().for_each(|e| { + print!( + "Experiment: \"{}\", Buckets: {} to {}, Branches: ", + e.id, e.bucket_info.count, e.bucket_info.start + ); + e.branches.iter().for_each(|b| print!(" \"{}\", ", b.name)); + println!() + }); + println!("You are in bucket: {}", exp.get_bucket()); + enrolled_exp.iter().for_each(|ee| { + println!( + "Enrolled in experiment \"{}\" in branch \"{}\"", + ee.get_id(), + ee.get_branch() + ) + }); + Ok(()) +} diff --git a/glean-core/nimbus-experiments/src/buckets.rs b/glean-core/nimbus-experiments/src/buckets.rs new file mode 100644 index 0000000000..0c3bf73fe9 --- /dev/null +++ b/glean-core/nimbus-experiments/src/buckets.rs @@ -0,0 +1,69 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//! This might be where the bucketing logic can go +//! It would be different from current experimentation tools +//! There is a namespacing concept to allow users to be in multiple +//! unrelated experiments at the same time. + +//! TODO: Implement the bucketing logic from the nimbus project +//! Current implementation implements simple bucketing logic based on +//! rngs and a uuid + +use uuid::Uuid; +use super::Experiment; +use std::convert::TryInto; +use rand::{rngs::StdRng, Rng, SeedableRng}; +use serde_derive::*; + +const MAX_BUCKET_NO: u32 = 10000; + +#[derive(Serialize, Deserialize, Debug, Clone)] +pub struct Bucket { + pub bucket_no: u32, + pub enrolled_experiments: Vec // TODO: Implement getters instead of making fields public +} + + +impl Bucket { + pub fn new(uuid: Uuid, all_experiments: &[Experiment]) -> Self { + let bucket_no: u32 = + u32::from_be_bytes(uuid.as_bytes()[..4].try_into().unwrap()) % MAX_BUCKET_NO; + let mut num = StdRng::seed_from_u64(bucket_no as u64); + let enrolled_experiments = all_experiments + .iter() + .filter_map(|e| { + let branch = num.gen::() % e.branches.len(); + if bucket_no > e.bucket_info.count && bucket_no < e.bucket_info.start { + Some(EnrolledExperiment { + id: e.id.clone(), + branch: e.branches[branch].name.clone(), + }) + } else { + None + } + }) + .collect::>(); + Self { + bucket_no, + enrolled_experiments, + } + } +} + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct EnrolledExperiment { + id: String, + branch: String, +} + +impl EnrolledExperiment { + pub fn get_id(&self) -> &String { + &self.id + } + + pub fn get_branch(&self) -> &String { + &self.branch + } +} diff --git a/glean-core/nimbus-experiments/src/error.rs b/glean-core/nimbus-experiments/src/error.rs new file mode 100644 index 0000000000..b38defe431 --- /dev/null +++ b/glean-core/nimbus-experiments/src/error.rs @@ -0,0 +1,33 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//! Not implemented yet!!! +//! This is purely boilerplate to communicate over the ffi +//! We should define real variants for our error and use proper +//! error propegation (we can use the `thiserror` crate for that) + +//! TODO: Implement proper error handling, this would include defining the error enum, +//! impl std::error::Error using `thiserror` and ensuring all errors are handled appropriately + +use ffi_support::{ErrorCode, ExternError}; +#[derive(Debug, thiserror::Error)] +pub enum Error { + #[error("Invalid")] + Invalid, +} + +pub type Result = std::result::Result; + +impl From for ExternError { + fn from(_: Error) -> ExternError { + let code = ErrorCode::new(1); + ExternError::new_error(code, "UNEXPECTED") + } +} + +impl Into for anyhow::Error { + fn into(self) -> Error { + Error::Invalid + } +} diff --git a/glean-core/nimbus-experiments/src/experiments.idl b/glean-core/nimbus-experiments/src/experiments.idl new file mode 100644 index 0000000000..823f66fbda --- /dev/null +++ b/glean-core/nimbus-experiments/src/experiments.idl @@ -0,0 +1,9 @@ +# This is a test file for defining WebIDL for uniffi +# For the time being, it is not used for anything! +# However, if we use uniffi in the future, we could define +# The api here. (Unless uniffi changes to a non WebIDL way (looking at you proc-macros)) +namespace experiments {}; +interface Experiments { + constructor(); + void get_experiment_branch(); +}; \ No newline at end of file diff --git a/glean-core/nimbus-experiments/src/experiments_msg_types.proto b/glean-core/nimbus-experiments/src/experiments_msg_types.proto new file mode 100644 index 0000000000..3ce63579e4 --- /dev/null +++ b/glean-core/nimbus-experiments/src/experiments_msg_types.proto @@ -0,0 +1,54 @@ +syntax = "proto2"; + +// Note half of this file is the proto from viaduct +// It beats the purpose having another proto for that, and this opens +// the door to all sorts of mismatch errors. So +// TODO: Figure out a way to ensure consistency between this file with the viaduct one + +package mozilla.telemetry.glean.protobuf; + +option java_package = "mozilla.telemetry.glean"; +option java_outer_classname = "MsgTypes"; +option swift_prefix = "MsgTypes_"; +option optimize_for = LITE_RUNTIME; + +message Request { + enum Method { + GET = 0; + HEAD = 1; + POST = 2; + PUT = 3; + DELETE = 4; + CONNECT = 5; + OPTIONS = 6; + TRACE = 7; + } + required Method method = 1; + required string url = 2; + optional bytes body = 3; + map headers = 4; + required bool follow_redirects = 5; + required bool use_caches = 6; + required int32 connect_timeout_secs = 7; + required int32 read_timeout_secs = 8; +} + +message Response { + // If this is present, nothing else is. + optional string exception_message = 1; + optional string url = 2; + optional int32 status = 3; + optional bytes body = 4; + map headers = 5; +} + +message AppContext { + optional string app_id = 1; + optional string app_version = 2; + optional string locale_language = 3; + optional string locale_country = 4; + optional string device_manufacturer = 5; + optional string device_model = 6; + optional string region = 7; + optional string debug_tag = 8; +} diff --git a/glean-core/nimbus-experiments/src/ffi.rs b/glean-core/nimbus-experiments/src/ffi.rs new file mode 100644 index 0000000000..e12c7ff083 --- /dev/null +++ b/glean-core/nimbus-experiments/src/ffi.rs @@ -0,0 +1,69 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +use std::os::raw::c_char; + +use super::{error::Result, msg_types, AppContext, Experiments}; +use ffi_support::{define_handle_map_deleter, ConcurrentHandleMap, ExternError, FfiStr}; + +lazy_static::lazy_static! { + static ref EXPERIMENTS: ConcurrentHandleMap = ConcurrentHandleMap::new(); +} + +#[no_mangle] +pub extern "C" fn experiments_new( + app_ctx: *const u8, + app_ctx_len: i32, + db_path: FfiStr<'_>, + error: &mut ExternError, +) -> u64 { + EXPERIMENTS.insert_with_result(error, || -> Result { + let app_ctx = unsafe { + from_protobuf_ptr::(app_ctx, app_ctx_len).unwrap() + }; // Todo: make the whole function unsafe and implement proper error handling in error.rs + log::info!("=================== Initializing experiments ========================"); + Ok(Experiments::new(app_ctx, db_path.as_str())) + }) +} + +#[no_mangle] +pub extern "C" fn experiments_get_branch( + handle: u64, + branch: FfiStr<'_>, + error: &mut ExternError, +) -> *mut c_char { + EXPERIMENTS.call_with_result(error, handle, |experiment| -> Result { + log::info!("==================== Getting branch ========================"); + let branch_name = experiment.get_experiment_branch(branch.as_str())?; + Ok(branch_name) + }) +} + +define_handle_map_deleter!(EXPERIMENTS, experiements_destroy); + +/// # Safety +/// data is a raw pointer to the protobuf data +/// get_buffer will return an error if the length is invalid, +/// or if the pointer is a null pointer +pub unsafe fn from_protobuf_ptr>( + data: *const u8, + len: i32, +) -> anyhow::Result { + let buffer = get_buffer(data, len)?; + let item: Result = prost::Message::decode(buffer); + item.map(|inner| inner.into()).map_err(|e| e.into()) +} + +unsafe fn get_buffer<'a>(data: *const u8, len: i32) -> anyhow::Result<&'a [u8]> { + match len { + len if len < 0 => anyhow::bail!("Invalid length"), + 0 => Ok(&[]), + _ => { + if data.is_null() { + anyhow::bail!("Null pointer") + } + Ok(std::slice::from_raw_parts(data, len as usize)) + } + } +} diff --git a/glean-core/nimbus-experiments/src/http_client.rs b/glean-core/nimbus-experiments/src/http_client.rs new file mode 100644 index 0000000000..da924ae7cc --- /dev/null +++ b/glean-core/nimbus-experiments/src/http_client.rs @@ -0,0 +1,85 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//! This is a simple Http client that uses viaduct to retrieve experiment data from the server +//! Currently configured to use Kinto and the old schema, although that would change once we start +//! Working on the real Nimbus schema. + +use super::Experiment; +use anyhow::Result; +use serde_derive::*; +use url::Url; +use viaduct::{status_codes, Request, Response}; + +// Making this a trait so that we can mock those later. +pub(crate) trait SettingsClient { + fn get_experiements_metadata(&self) -> Result; + fn get_experiments(&self) -> Result>; +} + +#[derive(Deserialize)] +struct RecordsResponse { + data: Vec, +} + +pub struct Client { + base_url: Url, + collection_name: String, + bucket_name: String, +} + +impl Client { + pub fn new(base_url: Url, collection_name: String, bucket_name: String) -> Self { + Self { + base_url, + collection_name, + bucket_name, + } + } + + fn make_request(&self, request: Request) -> Result { + let resp = request.send()?; + if resp.is_success() || resp.status == status_codes::NOT_MODIFIED { + Ok(resp) + } else { + anyhow::bail!("Error in request: {}", resp.text()) + } + } +} + +impl SettingsClient for Client { + fn get_experiements_metadata(&self) -> Result { + let path = format!( + "buckets/{}/collections/{}", + &self.bucket_name, &self.collection_name + ); + let url = self.base_url.join(&path)?; + let req = Request::get(url).header( + "User-Agent", + "Experiments Rust Component ", + )?; + let resp = self.make_request(req)?; + let res = serde_json::to_string(&resp.body)?; + Ok(res) + } + + fn get_experiments(&self) -> Result> { + let path = format!( + "buckets/{}/collections/{}/records", + &self.bucket_name, &self.collection_name + ); + let url = self.base_url.join(&path)?; + let req = Request::get(url).header( + "User-Agent", + "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:77.0) Gecko/20100101 Firefox/77.0", + )?; + // TODO: Add authentication based on server requirements + let resp = self.make_request(req)?.json::()?; + Ok(resp.data) + } +} + +// TODO: Implement unit tests +// A We could use mockito (not mockiato) to mock the network requests here +// and ensure that we handle all the edge cases diff --git a/glean-core/nimbus-experiments/src/lib.rs b/glean-core/nimbus-experiments/src/lib.rs new file mode 100644 index 0000000000..15f419fff2 --- /dev/null +++ b/glean-core/nimbus-experiments/src/lib.rs @@ -0,0 +1,148 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//! Experiments library that hopes to be cross-plateform. +//! Still a work in progress, but good enough for people to poke around + +mod buckets; +pub mod error; +pub mod ffi; +mod http_client; +mod persistence; +mod matcher; + + +use error::Result; +pub use ffi::{experiements_destroy, experiments_get_branch, experiments_new}; +use http_client::{Client, SettingsClient}; +use persistence::Database; +use serde_derive::*; +use std::path::Path; +use url::Url; +use uuid::Uuid; +pub use viaduct; +use matcher::Matcher; +use buckets::{Bucket, EnrolledExperiment}; +pub use matcher::{AppContext}; // We expose this for the client to set + +const BASE_URL: &str = "https://kinto.dev.mozaws.net/v1/"; +const COLLECTION_NAME: &str = "messaging-collection"; +const BUCKET_NAME: &str = "main"; + +// We'll probably end up doing what is done in A-S with regards to +// protobufs if we take this route... +// But for now, using the build.rs seems convenient +// ref: https://github.com/mozilla/application-services/tree/main/tools/protobuf-gen +pub mod msg_types { + include!(concat!( + env!("OUT_DIR"), + "/mozilla.telemetry.glean.protobuf.rs" + )); +} + +/// Experiments is the main struct representing the experiements state +/// It should hold all the information needed to communcate a specific user's +/// Experiementation status (note: This should have some type of uuid) +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct Experiments { + // Uuid not used yet, but we'll be using it later + #[allow(unused)] + uuid: Uuid, + #[allow(unused)] + app_ctx: AppContext, + experiments: Vec, + bucket: Bucket, +} + +impl Experiments { + /// A new experiments struct is created, this is where some preprocessing happens + /// It should look for persisted state first and setup some type + /// Of interval retrieval from the server for any experiment updates (not implemented) + pub fn new>(app_ctx: AppContext, path: P) -> Self { + let database = Database::new(path).unwrap(); + let persisted_data= database.get::("persisted").unwrap(); + if let Some(inner) = persisted_data { + log::info!("Retrieving data from persisted state..."); + return inner; + } + // TODO: Implement a type of interval schedule to check with the server for any + // updates + let http_client = Client::new( + Url::parse(BASE_URL).unwrap(), + COLLECTION_NAME.to_string(), + BUCKET_NAME.to_string(), + ); + let resp = http_client.get_experiments().unwrap(); + let uuid = uuid::Uuid::new_v4(); + let bucket = Bucket::new(uuid, &resp); + let experiments = Self { + app_ctx, + uuid, + experiments: resp, + bucket, + }; + + database + .put( + "persisted", // TODO: Think about a more appropriate key situation for persistance + &experiments + ) + .unwrap(); + experiments + } + + /// Retrieves the branch the user is in, in the experiment. Errors if the user is not enrolled (This should be an option, but for ffi + test it errors) + pub fn get_experiment_branch(&self, exp_name: &str) -> Result { + self.bucket + .enrolled_experiments + .iter() + .find(|e| e.get_id() == exp_name) + .map(|e| e.get_branch().clone()) + .ok_or_else(|| anyhow::format_err!("No branch").into()) // Should be returning an option! But for now... + } + + pub fn get_enrolled_experiments(&self) -> &Vec { + &self.bucket.enrolled_experiments + } + + pub fn get_experiments(&self) -> &Vec { + &self.experiments + } + + pub fn get_bucket(&self) -> u32 { + self.bucket.bucket_no + } +} + +// ============ Below are a bunch of types that gets serialized/deserialized and stored in our `Experiments` struct ============ +// ============ They currently follow the old schema, and need to be updated to match the new Nimbus schema ============ + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct Experiment { + pub id: String, + pub description: String, + pub last_modified: u64, + pub schema_modified: Option, + #[serde(rename = "buckets")] + pub bucket_info: BucketInfo, + pub branches: Vec, + #[serde(rename = "match")] + pub matcher: Matcher, +} + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct BucketInfo { + pub count: u32, + pub start: u32, +} + +#[derive(Deserialize, Serialize, Debug, Clone)] +pub struct Branch { + pub name: String, + ratio: u32, +} + +// TODO: Implement unit tests +// A We could use mockiato to mock the trait functions +// of the http client, and test the main functionality here diff --git a/glean-core/nimbus-experiments/src/matcher.rs b/glean-core/nimbus-experiments/src/matcher.rs new file mode 100644 index 0000000000..ba450f6f15 --- /dev/null +++ b/glean-core/nimbus-experiments/src/matcher.rs @@ -0,0 +1,51 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + //! THis module defines all the information needed to match a user with an experiment + //! this module should also include a `match` function of some sort that does the matching + //! tt has two main types, the `matcher` retrieved from the server, and the `AppContext` + //! from the client +use serde_derive::*; +use super::msg_types; + +#[derive(Deserialize, Serialize, Debug, Clone, Default)] +pub struct Matcher { + pub app_id: Option, + pub app_display_version: Option, + pub app_min_version: Option, // Do what AC does and have a VersionOptionString instead? + pub app_max_version: Option, //Dito + pub locale_language: Option, + pub locale_country: Option, + pub device_manufacturer: Option, + pub device_model: Option, + pub regions: Vec, + pub debug_tags: Vec, +} + +#[derive(Deserialize, Serialize, Debug, Clone, Default)] +pub struct AppContext { + pub app_id: Option, + pub app_version: Option, + pub locale_language: Option, + pub locale_country: Option, + pub device_manufacturer: Option, + pub device_model: Option, + pub region: Option, + pub debug_tag: Option, +} + +impl From for AppContext { + fn from(proto_ctx: msg_types::AppContext) -> Self { + Self { + app_id: proto_ctx.app_id, + app_version: proto_ctx.app_version, + locale_language: proto_ctx.locale_language, + locale_country: proto_ctx.locale_country, + device_manufacturer: proto_ctx.device_manufacturer, + device_model: proto_ctx.device_model, + region: proto_ctx.region, + debug_tag: proto_ctx.debug_tag, + } + } +} \ No newline at end of file diff --git a/glean-core/nimbus-experiments/src/persistence.rs b/glean-core/nimbus-experiments/src/persistence.rs new file mode 100644 index 0000000000..5bd03a142b --- /dev/null +++ b/glean-core/nimbus-experiments/src/persistence.rs @@ -0,0 +1,65 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//! This is where the persistence logic might go. +//! An idea for what to use here might be [RKV](https://github.com/mozilla/rkv) +//! And that's what's used on this prototype, +//! Either ways, the solution implemented should work regardless of the platform +//! on the other side of the FFI. This means that this module might require the FFI to allow consumers +//! To pass in a path to a database, or somewhere in the file system that the state will be persisted +use anyhow::Result; +use rkv::{Rkv, SingleStore, StoreOptions}; +use std::fs; +use std::path::Path; + +pub struct Database { + rkv: Rkv, + + experiment_store: SingleStore, +} + +impl Database { + pub fn new>(path: P) -> Result { + let rkv = Self::open_rkv(path)?; + let experiment_store = rkv + .open_single("experiments", StoreOptions::create()) + .unwrap(); + Ok(Self { + rkv, + experiment_store, + }) + } + + fn open_rkv>(path: P) -> Result { + let path = std::path::Path::new(path.as_ref()).join("db"); + log::debug!("Database path: {:?}", path.display()); + fs::create_dir_all(&path)?; + + let rkv = Rkv::new(&path).unwrap(); // TODO: Impl proper error handling in an error.rs that can propagate this + log::info!("Database initialized"); + Ok(rkv) + } + + pub fn get serde::Deserialize<'de>>(&self, key: &str) -> Result> { + let reader = self.rkv.read().unwrap(); + let val = self.experiment_store.get(&reader, key).unwrap(); + Ok(val.map(|v| { + if let rkv::Value::Json(val) = v { + val.to_string() + } else { + "".to_string() + } + }).map(|s| serde_json::from_str::(&s).unwrap())) // TODO: Error handling here to prevent panics + } + + pub fn put serde::Deserialize<'de>>(&self, key: &str, persisted_data: &T) -> Result<()> { + let mut writer = self.rkv.write().unwrap(); + let persisted_json = serde_json::to_string(persisted_data).unwrap(); + self.experiment_store + .put(&mut writer, key, &rkv::Value::Json(&persisted_json)) + .unwrap(); + writer.commit().unwrap(); // TODO: Error handling + Ok(()) + } +}