diff --git a/Cargo.lock b/Cargo.lock index 583b290..3659eeb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,73 +2,220 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "actix-codec" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d5dbeb2d9e51344cb83ca7cc170f1217f9fe25bfc50160e6e200b5c31c1019a" +dependencies = [ + "bitflags", + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", + "tokio-util", +] + +[[package]] +name = "actix-http" +version = "3.0.0-beta.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cd16d6b846983ffabfd081e1a67abd7698094fcbe7b3d9bcf1acbc6f546a516" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-tls", + "actix-utils", + "ahash", + "base64", + "bitflags", + "brotli2", + "bytes", + "bytestring", + "derive_more", + "encoding_rs", + "flate2", + "futures-core", + "futures-util", + "h2", + "http", + "httparse", + "itoa", + "language-tags", + "local-channel", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project", + "pin-project-lite", + "rand", + "regex", + "serde", + "sha-1", + "smallvec", + "time", + "tokio", + "zstd", +] + +[[package]] +name = "actix-macros" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2f86cd6857c135e6e9fe57b1619a88d1f94a7df34c00e11fe13e64fd3438837" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-router" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ad299af73649e1fc893e333ccf86f377751eb95ff875d095131574c6f43452c" +dependencies = [ + "bytestring", + "http", + "log", + "regex", + "serde", +] + +[[package]] +name = "actix-rt" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc7d7cd957c9ed92288a7c3c96af81fa5291f65247a76a34dac7b6af74e52ba0" +dependencies = [ + "actix-macros", + "futures-core", + "tokio", +] + +[[package]] +name = "actix-server" +version = "2.0.0-beta.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26369215fcc3b0176018b3b68756a8bcc275bb000e6212e454944913a1f9bf87" +dependencies = [ + "actix-rt", + "actix-service", + "actix-utils", + "futures-core", + "log", + "mio", + "num_cpus", + "slab", + "tokio", +] + +[[package]] +name = "actix-service" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77f5f9d66a8730d0fae62c26f3424f5751e5518086628a40b7ab6fca4a705034" +dependencies = [ + "futures-core", + "paste", + "pin-project-lite", +] + +[[package]] +name = "actix-tls" +version = "3.0.0-beta.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65b7bb60840962ef0332f7ea01a57d73a24d2cb663708511ff800250bbfef569" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "derive_more", + "futures-core", + "http", + "log", + "tokio-util", +] + +[[package]] +name = "actix-utils" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e491cbaac2e7fc788dfff99ff48ef317e23b3cf63dbaf7aaab6418f40f92aa94" +dependencies = [ + "local-waker", + "pin-project-lite", +] + +[[package]] +name = "actix-web" +version = "4.0.0-beta.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c503f726f895e55dac39adeafd14b5ee00cc956796314e9227fc7ae2e176f443" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-utils", + "actix-web-codegen", + "ahash", + "bytes", + "cfg-if", + "cookie", + "derive_more", + "either", + "encoding_rs", + "futures-core", + "futures-util", + "itoa", + "language-tags", + "log", + "mime", + "once_cell", + "paste", + "pin-project", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "smallvec", + "socket2", + "time", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "0.5.0-beta.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d048c6986743105c1e8e9729fbc8d5d1667f2f62393a58be8d85a7d9a5a6c8d" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "adler" version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "aead" -version = "0.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc95d1bdb8e6666b2b217308eeeb09f2d6728d104be3e31916cc74d15420331" -dependencies = [ - "generic-array", -] - -[[package]] -name = "aes" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "884391ef1066acaa41e766ba8f596341b96e93ce34f9a43e7d24bf0a0eaf0561" -dependencies = [ - "aes-soft", - "aesni", - "cipher", -] - -[[package]] -name = "aes-gcm" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5278b5fabbb9bd46e24aa69b2fdea62c99088e0a950a9be40e3e0101298f88da" -dependencies = [ - "aead", - "aes", - "cipher", - "ctr", - "ghash", - "subtle", -] - -[[package]] -name = "aes-soft" -version = "0.6.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be14c7498ea50828a38d0e24a765ed2effe92a705885b57d029cd67d45744072" -dependencies = [ - "cipher", - "opaque-debug", -] - -[[package]] -name = "aesni" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea2e11f5e94c2f7d386164cc2aa1f97823fed6f259e486940a71c174dd01b0ce" -dependencies = [ - "cipher", - "opaque-debug", -] - [[package]] name = "ahash" version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "43bb833f0bf979d8475d38fbf09ed3b8a55e1885fe93ad3f93239fc6a4f17b98" dependencies = [ - "getrandom 0.2.3", + "getrandom", "once_cell", "version_check", ] @@ -91,238 +238,12 @@ dependencies = [ "winapi", ] -[[package]] -name = "anyhow" -version = "1.0.42" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "595d3cfa7a60d4555cb5067b99f07142a08ea778de5cf993f7b75c7d8fabc486" - -[[package]] -name = "arrayref" -version = "0.3.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4c527152e37cf757a3f78aae5a06fbeefdb07ccc535c980a3208ee3060dd544" - [[package]] name = "arrayvec" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b" -[[package]] -name = "async-attributes" -version = "1.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a3203e79f4dd9bdda415ed03cf14dae5a2bf775c683a00f94e9cd1faf0f596e5" -dependencies = [ - "quote", - "syn", -] - -[[package]] -name = "async-channel" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2114d64672151c0c5eaa5e131ec84a74f06e1e559830dabba01ca30605d66319" -dependencies = [ - "concurrent-queue", - "event-listener", - "futures-core", -] - -[[package]] -name = "async-dup" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7427a12b8dc09291528cfb1da2447059adb4a257388c2acd6497a79d55cf6f7c" -dependencies = [ - "futures-io", - "simple-mutex", -] - -[[package]] -name = "async-executor" -version = "1.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "871f9bb5e0a22eeb7e8cf16641feb87c9dc67032ccf8ff49e772eb9941d3a965" -dependencies = [ - "async-task", - "concurrent-queue", - "fastrand", - "futures-lite", - "once_cell", - "slab", -] - -[[package]] -name = "async-global-executor" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9586ec52317f36de58453159d48351bc244bc24ced3effc1fce22f3d48664af6" -dependencies = [ - "async-channel", - "async-executor", - "async-io", - "async-mutex", - "blocking", - "futures-lite", - "num_cpus", - "once_cell", -] - -[[package]] -name = "async-h1" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc5142de15b549749cce62923a50714b0d7b77f5090ced141599e78899865451" -dependencies = [ - "async-channel", - "async-dup", - "async-std", - "byte-pool", - "futures-core", - "http-types", - "httparse", - "lazy_static", - "log", - "pin-project", -] - -[[package]] -name = "async-io" -version = "1.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a811e6a479f2439f0c04038796b5cfb3d2ad56c230e0f2d3f7b04d68cfee607b" -dependencies = [ - "concurrent-queue", - "futures-lite", - "libc", - "log", - "once_cell", - "parking", - "polling", - "slab", - "socket2", - "waker-fn", - "winapi", -] - -[[package]] -name = "async-lock" -version = "2.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6a8ea61bf9947a1007c5cada31e647dbc77b103c679858150003ba697ea798b" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-mutex" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "479db852db25d9dbf6204e6cb6253698f175c15726470f78af0d918e99d6156e" -dependencies = [ - "event-listener", -] - -[[package]] -name = "async-process" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f38756dd9ac84671c428afbf7c9f7495feff9ec5b0710f17100098e5b354ac" -dependencies = [ - "async-io", - "blocking", - "cfg-if 1.0.0", - "event-listener", - "futures-lite", - "libc", - "once_cell", - "signal-hook", - "winapi", -] - -[[package]] -name = "async-rustls" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c86f33abd5a4f3e2d6d9251a9e0c6a7e52eb1113caf893dae8429bf4a53f378" -dependencies = [ - "futures-lite", - "rustls", - "webpki", -] - -[[package]] -name = "async-session" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "345022a2eed092cd105cc1b26fd61c341e100bd5fcbbd792df4baf31c2cc631f" -dependencies = [ - "anyhow", - "async-std", - "async-trait", - "base64 0.12.3", - "bincode", - "blake3", - "chrono", - "hmac 0.8.1", - "kv-log-macro", - "rand 0.7.3", - "serde", - "serde_json", - "sha2", -] - -[[package]] -name = "async-sse" -version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "53bba003996b8fd22245cd0c59b869ba764188ed435392cf2796d03b805ade10" -dependencies = [ - "async-channel", - "async-std", - "http-types", - "log", - "memchr", - "pin-project-lite 0.1.12", -] - -[[package]] -name = "async-std" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9f06685bad74e0570f5213741bea82158279a4103d988e57bfada11ad230341" -dependencies = [ - "async-attributes", - "async-channel", - "async-global-executor", - "async-io", - "async-lock", - "async-process", - "crossbeam-utils", - "futures-channel", - "futures-core", - "futures-io", - "futures-lite", - "gloo-timers", - "kv-log-macro", - "log", - "memchr", - "num_cpus", - "once_cell", - "pin-project-lite 0.2.7", - "pin-utils", - "slab", - "wasm-bindgen-futures", -] - -[[package]] -name = "async-task" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e91831deabf0d6d7ec49552e489aed63b7456a7a3c46cff62adad428110b0af0" - [[package]] name = "async-trait" version = "0.1.50" @@ -343,12 +264,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "atomic-waker" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "065374052e7df7ee4047b1160cca5e1467a12351a40b3da123c870ba0b8eda2a" - [[package]] name = "autocfg" version = "1.0.1" @@ -361,27 +276,12 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" -[[package]] -name = "base64" -version = "0.12.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff" - [[package]] name = "base64" version = "0.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" -[[package]] -name = "bincode" -version = "1.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad" -dependencies = [ - "serde", -] - [[package]] name = "bitflags" version = "1.2.1" @@ -414,7 +314,9 @@ dependencies = [ name = "bkapi" version = "0.1.0" dependencies = [ - "async-std", + "actix-http", + "actix-service", + "actix-web", "bk-tree", "envconfig", "futures", @@ -422,35 +324,19 @@ dependencies = [ "lazy_static", "opentelemetry", "opentelemetry-jaeger", - "opentelemetry-semantic-conventions", "prometheus", "serde", "serde_json", "sqlx", "thiserror", - "tide", - "tide-tracing", + "tokio", "tracing", + "tracing-actix-web", "tracing-opentelemetry", "tracing-subscriber", "tracing-unwrap", ] -[[package]] -name = "blake3" -version = "0.3.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b64485778c4f16a6a5a9d335e80d449ac6c70cdd6a06d2af18a6f6f775a125b3" -dependencies = [ - "arrayref", - "arrayvec", - "cc", - "cfg-if 0.1.10", - "constant_time_eq", - "crypto-mac 0.8.0", - "digest", -] - [[package]] name = "block-buffer" version = "0.9.0" @@ -461,17 +347,23 @@ dependencies = [ ] [[package]] -name = "blocking" -version = "1.0.2" +name = "brotli-sys" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5e170dbede1f740736619b776d7251cb1b9095c435c34d8ca9f57fcd2f335e9" +checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" dependencies = [ - "async-channel", - "async-task", - "atomic-waker", - "fastrand", - "futures-lite", - "once_cell", + "cc", + "libc", +] + +[[package]] +name = "brotli2" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cb036c3eade309815c15ddbacec5b22c4d1f3983a774ab2eac2e3e9ea85568e" +dependencies = [ + "brotli-sys", + "libc", ] [[package]] @@ -486,16 +378,6 @@ version = "3.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9c59e7af012c713f529e7a3ee57ce9b31ddd858d4b512923602f74608b009631" -[[package]] -name = "byte-pool" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f8c7230ddbb427b1094d477d821a99f3f54d36333178eeb806e279bcdcecf0ca" -dependencies = [ - "crossbeam-queue", - "stable_deref_trait", -] - [[package]] name = "byteorder" version = "1.4.3" @@ -509,22 +391,22 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040" [[package]] -name = "cache-padded" -version = "1.1.1" +name = "bytestring" +version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "631ae5198c9be5e753e5cc215e1bd73c2b466a3565173db433f52bb9d3e66dba" +checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" +dependencies = [ + "bytes", +] [[package]] name = "cc" version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e70cc2f62c6ce1868963827bd677764c62d07c3d9a3e1fb1177ee1a9ab199eb2" - -[[package]] -name = "cfg-if" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +dependencies = [ + "jobserver", +] [[package]] name = "cfg-if" @@ -541,29 +423,9 @@ dependencies = [ "libc", "num-integer", "num-traits", - "serde", - "time 0.1.43", "winapi", ] -[[package]] -name = "cipher" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12f8e7987cbd042a63249497f41aed09f8e65add917ea6566effbc56578d6801" -dependencies = [ - "generic-array", -] - -[[package]] -name = "concurrent-queue" -version = "1.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30ed07550be01594c6026cff2a1d7fe9c8f683caa798e12b68694ac9e88286a3" -dependencies = [ - "cache-padded", -] - [[package]] name = "const_fn" version = "0.4.8" @@ -571,25 +433,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" [[package]] -name = "constant_time_eq" -version = "0.1.5" +name = "convert_case" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc" +checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cookie" -version = "0.14.4" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951" +checksum = "d5f1c7727e460397e56abc4bddc1d49e07a1ad78fc98eb2e1c8f032a58a2f80d" dependencies = [ - "aes-gcm", - "base64 0.13.0", - "hkdf", - "hmac 0.10.1", "percent-encoding", - "rand 0.8.4", - "sha2", - "time 0.2.27", + "time", "version_check", ] @@ -602,12 +458,6 @@ dependencies = [ "libc", ] -[[package]] -name = "cpuid-bool" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcb25d077389e53838a8158c8e99174c5a9d902dee4904320db714f3c653ffba" - [[package]] name = "crc" version = "1.8.1" @@ -623,7 +473,7 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -632,7 +482,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "06ed27e177f16d65f0f0c22a213e17c696ace5dd64b14258b52f9417ccb52db4" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", ] @@ -642,7 +492,7 @@ version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9b10ddc024425c88c2ad148c1b0fd53f4c6d38db9697c9f1588381212fa657c9" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crossbeam-utils", ] @@ -652,20 +502,10 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d82cfc11ce7f2c3faef78d8a684447b40d503d9681acebed6cb728d45940c4db" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "lazy_static", ] -[[package]] -name = "crypto-mac" -version = "0.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b584a330336237c1eecd3e94266efb216c56ed91225d634cb2991c5f3fd1aeab" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "crypto-mac" version = "0.10.1" @@ -677,40 +517,18 @@ dependencies = [ ] [[package]] -name = "ctor" -version = "0.1.20" +name = "derive_more" +version = "0.99.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e98e2ad1a782e33928b96fc3948e7c355e5af34ba4de7670fe8bac2a3b2006d" +checksum = "40eebddd2156ce1bb37b20bbe5151340a31828b1f2d22ba4141f3531710e38df" dependencies = [ + "convert_case", + "proc-macro2", "quote", + "rustc_version 0.3.3", "syn", ] -[[package]] -name = "ctr" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb4a30d54f7443bf3d6191dcd486aca19e67cb3c49fa7a06a319966346707e7f" -dependencies = [ - "cipher", -] - -[[package]] -name = "dashmap" -version = "4.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e77a43b28d0668df09411cb0bc9a8c2adc40f9a048afe863e05fd43251e8e39c" -dependencies = [ - "cfg-if 1.0.0", - "num_cpus", -] - -[[package]] -name = "data-encoding" -version = "2.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ee2393c4a91429dffb4bedf19f4d6abf27d8a732c8ce4980305d782e5426d57" - [[package]] name = "digest" version = "0.9.0" @@ -758,6 +576,15 @@ version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +[[package]] +name = "encoding_rs" +version = "0.8.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" +dependencies = [ + "cfg-if", +] + [[package]] name = "envconfig" version = "0.10.0" @@ -778,44 +605,13 @@ dependencies = [ "syn", ] -[[package]] -name = "event-listener" -version = "2.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7531096570974c3a9dcf9e4b8e1cede1ec26cf5046219fb3b9d897503b9be59" - -[[package]] -name = "fastrand" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b394ed3d285a429378d3b384b9eb1285267e7df4b166df24b7a6939a04dc392e" -dependencies = [ - "instant", -] - -[[package]] -name = "femme" -version = "2.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2af1a24f391a5a94d756db5092c6576aad494b88a71a5a36b20c67b63e0df034" -dependencies = [ - "cfg-if 0.1.10", - "js-sys", - "log", - "serde", - "serde_derive", - "serde_json", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "flate2" version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cd3aec53de10fe96d7d8c565eb17f2c687bb5518a2ec453b5b1252964526abe0" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "crc32fast", "libc", "miniz_oxide", @@ -891,21 +687,6 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b0e06c393068f3a6ef246c75cdca793d6a46347e75286933e5e75fd2fd11582" -[[package]] -name = "futures-lite" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7694489acd39452c77daa48516b894c153f192c3578d5a839b62c58099fcbf48" -dependencies = [ - "fastrand", - "futures-core", - "futures-io", - "memchr", - "parking", - "pin-project-lite 0.2.7", - "waker-fn", -] - [[package]] name = "futures-macro" version = "0.3.16" @@ -945,7 +726,7 @@ dependencies = [ "futures-sink", "futures-task", "memchr", - "pin-project-lite 0.2.7", + "pin-project-lite", "pin-utils", "proc-macro-hack", "proc-macro-nested", @@ -962,49 +743,34 @@ dependencies = [ "version_check", ] -[[package]] -name = "getrandom" -version = "0.1.16" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "wasi 0.9.0+wasi-snapshot-preview1", -] - [[package]] name = "getrandom" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "libc", - "wasi 0.10.2+wasi-snapshot-preview1", + "wasi", ] [[package]] -name = "ghash" -version = "0.3.1" +name = "h2" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97304e4cd182c3846f7575ced3890c53012ce534ad9114046b0a9e00bb30a375" +checksum = "825343c4eef0b63f541f8903f395dc5beb362a979b5799a84062527ef1e37726" dependencies = [ - "opaque-debug", - "polyval", -] - -[[package]] -name = "gloo-timers" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47204a46aaff920a1ea58b11d03dec6f704287d27561724a4631e450654a891f" -dependencies = [ - "futures-channel", + "bytes", + "fnv", "futures-core", - "js-sys", - "wasm-bindgen", - "web-sys", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", ] [[package]] @@ -1055,69 +821,25 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" -[[package]] -name = "hkdf" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51ab2f639c231793c5f6114bdb9bbe50a7dbbfcd7c7c6bd8475dec2d991e964f" -dependencies = [ - "digest", - "hmac 0.10.1", -] - -[[package]] -name = "hmac" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "126888268dcc288495a26bf004b38c5fdbb31682f992c84ceb046a1f0fe38840" -dependencies = [ - "crypto-mac 0.8.0", - "digest", -] - [[package]] name = "hmac" version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ - "crypto-mac 0.10.1", + "crypto-mac", "digest", ] [[package]] -name = "http-client" -version = "6.4.1" +name = "http" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ce318d86a47d18d1db645c979214f809a6cd625202ad334ef75ca813b30dac80" +checksum = "527e8c9ac747e28542699a951517aa9a6945af506cd1f2e1b53a576c17b6cc11" dependencies = [ - "async-trait", - "cfg-if 1.0.0", - "dashmap", - "http-types", - "log", -] - -[[package]] -name = "http-types" -version = "2.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad077d89137cd3debdce53c66714dc536525ef43fe075d41ddc0a8ac11f85957" -dependencies = [ - "anyhow", - "async-channel", - "async-std", - "base64 0.13.0", - "cookie", - "futures-lite", - "infer", - "pin-project-lite 0.2.7", - "rand 0.7.3", - "serde", - "serde_json", - "serde_qs", - "serde_urlencoded", - "url", + "bytes", + "fnv", + "itoa", ] [[package]] @@ -1138,10 +860,14 @@ dependencies = [ ] [[package]] -name = "infer" -version = "0.2.3" +name = "indexmap" +version = "1.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e9829a50b42bb782c1df523f78d332fe371b10c661e78b7a3c34b0198e9fac" +checksum = "bc633605454125dec4b66843673f01c7df2b89479b32e0ed634e43a91cff62a5" +dependencies = [ + "autocfg", + "hashbrown", +] [[package]] name = "instant" @@ -1149,7 +875,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bee0328b1209d157ef001c94dd85b4f8f64139adb0eac2659f4b08382b2f474d" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", ] [[package]] @@ -1164,6 +890,15 @@ version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd25036021b0de88a0aff6b850051563c6516d0bf53f8638938edbb9de732736" +[[package]] +name = "jobserver" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "972f5ae5d1cb9c6ae417789196c803205313edde988685da5e3aae0827b9e7fd" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.51" @@ -1174,13 +909,10 @@ dependencies = [ ] [[package]] -name = "kv-log-macro" -version = "1.0.7" +name = "language-tags" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0de8b303297635ad57c9f5059fd9cee7a47f8e8daa09df0fcd07dd39fb22977f" -dependencies = [ - "log", -] +checksum = "d4345964bb142484797b161f473a503a434de77149dd8c7427788c6e13379388" [[package]] name = "lazy_static" @@ -1196,7 +928,7 @@ checksum = "6607c62aa161d23d17a9072cc5da0be67cdfc89d3afb1e8d9c842bebc2525ffe" dependencies = [ "arrayvec", "bitflags", - "cfg-if 1.0.0", + "cfg-if", "ryu", "static_assertions", ] @@ -1207,6 +939,24 @@ version = "0.2.98" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "320cfe77175da3a483efed4bc0adc1968ca050b098ce4f2f1c13a56626128790" +[[package]] +name = "local-channel" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6246c68cf195087205a0512559c97e15eaf95198bf0e206d662092cdcb03fe9f" +dependencies = [ + "futures-core", + "futures-sink", + "futures-util", + "local-waker", +] + +[[package]] +name = "local-waker" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84f9a2d3e27ce99ce2c3aad0b09b1a7b916293ea9b2bf624c13fe646fadd8da4" + [[package]] name = "lock_api" version = "0.4.4" @@ -1222,8 +972,7 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" dependencies = [ - "cfg-if 1.0.0", - "value-bag", + "cfg-if", ] [[package]] @@ -1264,6 +1013,12 @@ version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b16bd47d9e329435e309c58469fe0791c2d0d1ba96ec0954152a5ae2b04387dc" +[[package]] +name = "mime" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" + [[package]] name = "miniz_oxide" version = "0.4.4" @@ -1274,6 +1029,28 @@ dependencies = [ "autocfg", ] +[[package]] +name = "mio" +version = "0.7.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" +dependencies = [ + "libc", + "log", + "miow", + "ntapi", + "winapi", +] + +[[package]] +name = "miow" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +dependencies = [ + "winapi", +] + [[package]] name = "nom" version = "6.1.2" @@ -1287,6 +1064,15 @@ dependencies = [ "version_check", ] +[[package]] +name = "ntapi" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +dependencies = [ + "winapi", +] + [[package]] name = "num-integer" version = "0.1.44" @@ -1334,7 +1120,6 @@ version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff27b33e30432e7b9854936693ca103d8591b0501f7ae9f633de48cda3bf2a67" dependencies = [ - "async-std", "async-trait", "crossbeam-channel", "futures", @@ -1342,8 +1127,10 @@ dependencies = [ "lazy_static", "percent-encoding", "pin-project", - "rand 0.8.4", + "rand", "thiserror", + "tokio", + "tokio-stream", ] [[package]] @@ -1359,15 +1146,6 @@ dependencies = [ "thrift", ] -[[package]] -name = "opentelemetry-semantic-conventions" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "748502c9b5621d7f0fe9cf26cb75bc773a04ce8f1c2b9ce44c3e01045aac6b6d" -dependencies = [ - "opentelemetry", -] - [[package]] name = "ordered-float" version = "1.1.1" @@ -1377,12 +1155,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "parking" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "427c3892f9e783d91cc128285287e70a59e206ca452770ece88a76f7a3eddd72" - [[package]] name = "parking_lot" version = "0.11.1" @@ -1400,7 +1172,7 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fa7a782938e745763fe6907fc6ba86946d72f49fe7e21de074e08128a99fb018" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "instant", "libc", "redox_syscall", @@ -1408,12 +1180,27 @@ dependencies = [ "winapi", ] +[[package]] +name = "paste" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "acbf547ad0c65e31259204bd90935776d1c693cec2f4ff7abb7a1bbbd40dfe58" + [[package]] name = "percent-encoding" version = "2.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" +[[package]] +name = "pest" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53" +dependencies = [ + "ucd-trie", +] + [[package]] name = "pin-project" version = "1.0.8" @@ -1434,12 +1221,6 @@ dependencies = [ "syn", ] -[[package]] -name = "pin-project-lite" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" - [[package]] name = "pin-project-lite" version = "0.2.7" @@ -1452,30 +1233,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" -[[package]] -name = "polling" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92341d779fa34ea8437ef4d82d440d5e1ce3f3ff7f824aa64424cd481f9a1f25" -dependencies = [ - "cfg-if 1.0.0", - "libc", - "log", - "wepoll-ffi", - "winapi", -] - -[[package]] -name = "polyval" -version = "0.4.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eebcc4aa140b9abd2bc40d9c3f7ccec842679cd79045ac3a7ac698c1a064b7cd" -dependencies = [ - "cpuid-bool", - "opaque-debug", - "universal-hash", -] - [[package]] name = "ppv-lite86" version = "0.2.10" @@ -1523,7 +1280,7 @@ version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5986aa8d62380092d2f50f8b1cdba9cb9b6731ffd4b25b51fd126b6c3e05b99c" dependencies = [ - "cfg-if 1.0.0", + "cfg-if", "fnv", "lazy_static", "libc", @@ -1555,19 +1312,6 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "941ba9d78d8e2f7ce474c015eea4d9c6d25b6a3327f9832ee29a4de27f91bbb8" -[[package]] -name = "rand" -version = "0.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" -dependencies = [ - "getrandom 0.1.16", - "libc", - "rand_chacha 0.2.2", - "rand_core 0.5.1", - "rand_hc 0.2.0", -] - [[package]] name = "rand" version = "0.8.4" @@ -1575,19 +1319,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" dependencies = [ "libc", - "rand_chacha 0.3.1", - "rand_core 0.6.3", - "rand_hc 0.3.1", -] - -[[package]] -name = "rand_chacha" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" -dependencies = [ - "ppv-lite86", - "rand_core 0.5.1", + "rand_chacha", + "rand_core", + "rand_hc", ] [[package]] @@ -1597,16 +1331,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" dependencies = [ "ppv-lite86", - "rand_core 0.6.3", -] - -[[package]] -name = "rand_core" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" -dependencies = [ - "getrandom 0.1.16", + "rand_core", ] [[package]] @@ -1615,16 +1340,7 @@ version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" dependencies = [ - "getrandom 0.2.3", -] - -[[package]] -name = "rand_hc" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" -dependencies = [ - "rand_core 0.5.1", + "getrandom", ] [[package]] @@ -1633,7 +1349,7 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" dependencies = [ - "rand_core 0.6.3", + "rand_core", ] [[package]] @@ -1651,7 +1367,7 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" dependencies = [ - "getrandom 0.2.3", + "getrandom", "redox_syscall", ] @@ -1696,19 +1412,22 @@ dependencies = [ "winapi", ] -[[package]] -name = "route-recognizer" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56770675ebc04927ded3e60633437841581c285dc6236109ea25fbf3beb7b59e" - [[package]] name = "rustc_version" version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" dependencies = [ - "semver", + "semver 0.9.0", +] + +[[package]] +name = "rustc_version" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0dfe2087c51c460008730de8b57e6a320782fbfb312e1f4d520e6c6fae155ee" +dependencies = [ + "semver 0.11.0", ] [[package]] @@ -1717,7 +1436,7 @@ version = "0.19.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "35edb675feee39aec9c99fa5ff985081995a06d594114ae14cbe797ad7b7a6d7" dependencies = [ - "base64 0.13.0", + "base64", "log", "ring", "sct", @@ -1752,7 +1471,16 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" dependencies = [ - "semver-parser", + "semver-parser 0.7.0", +] + +[[package]] +name = "semver" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6" +dependencies = [ + "semver-parser 0.10.2", ] [[package]] @@ -1761,6 +1489,15 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +[[package]] +name = "semver-parser" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7" +dependencies = [ + "pest", +] + [[package]] name = "serde" version = "1.0.126" @@ -1792,18 +1529,6 @@ dependencies = [ "serde", ] -[[package]] -name = "serde_qs" -version = "0.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5af82de3c6549b001bec34961ff2d6a54339a87bab37ce901b693401f27de6cb" -dependencies = [ - "data-encoding", - "percent-encoding", - "serde", - "thiserror", -] - [[package]] name = "serde_urlencoded" version = "0.7.0" @@ -1823,7 +1548,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1a0c8611594e2ab4ebbf06ec7cbbf0a99450b8570e96cbf5188b5d5f6ef18d81" dependencies = [ "block-buffer", - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest", "opaque-debug", @@ -1842,7 +1567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b362ae5752fd2137731f9fa25fd4d9058af34666ca1966fb969119cc35719f12" dependencies = [ "block-buffer", - "cfg-if 1.0.0", + "cfg-if", "cpufeatures", "digest", "opaque-debug", @@ -1857,16 +1582,6 @@ dependencies = [ "lazy_static", ] -[[package]] -name = "signal-hook" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "470c5a6397076fae0094aaf06a08e6ba6f37acb77d3b1b91ea92b4d6c8650c39" -dependencies = [ - "libc", - "signal-hook-registry", -] - [[package]] name = "signal-hook-registry" version = "1.4.0" @@ -1876,15 +1591,6 @@ dependencies = [ "libc", ] -[[package]] -name = "simple-mutex" -version = "1.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38aabbeafa6f6dead8cebf246fe9fae1f9215c8d29b3a69f93bd62a9e4a3dcd6" -dependencies = [ - "event-listener", -] - [[package]] name = "slab" version = "0.4.3" @@ -1899,9 +1605,9 @@ checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e" [[package]] name = "socket2" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e3dfc207c526015c632472a77be09cf1b6e46866581aecae5cc38fb4235dea2" +checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad" dependencies = [ "libc", "winapi", @@ -1944,7 +1650,7 @@ checksum = "7f23af36748ec8ea8d49ef8499839907be41b0b1178a4e82b8cb45d29f531dc9" dependencies = [ "ahash", "atoi", - "base64 0.13.0", + "base64", "bitflags", "byteorder", "bytes", @@ -1959,7 +1665,7 @@ dependencies = [ "futures-util", "hashlink", "hex", - "hmac 0.10.1", + "hmac", "itoa", "libc", "log", @@ -1968,7 +1674,7 @@ dependencies = [ "once_cell", "parking_lot", "percent-encoding", - "rand 0.8.4", + "rand", "rustls", "serde", "serde_json", @@ -1979,6 +1685,7 @@ dependencies = [ "sqlx-rt", "stringprep", "thiserror", + "tokio-stream", "url", "webpki", "webpki-roots", @@ -2011,16 +1718,12 @@ version = "0.5.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8199b421ecf3493ee9ef3e7bc90c904844cfb2ea7ea2f57347a93f52bfd3e057" dependencies = [ - "async-rustls", - "async-std", + "actix-rt", + "once_cell", + "tokio", + "tokio-rustls", ] -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "standback" version = "0.2.17" @@ -2043,7 +1746,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" dependencies = [ "discard", - "rustc_version", + "rustc_version 0.2.3", "stdweb-derive", "stdweb-internal-macros", "stdweb-internal-runtime", @@ -2101,12 +1804,6 @@ version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" -[[package]] -name = "sval" -version = "1.0.0-alpha.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45f6ee7c7b87caf59549e9fe45d6a69c75c8019e79e212a835c5da0e92f0ba08" - [[package]] name = "syn" version = "1.0.74" @@ -2175,51 +1872,6 @@ dependencies = [ "threadpool", ] -[[package]] -name = "tide" -version = "0.16.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c459573f0dd2cc734b539047f57489ea875af8ee950860ded20cf93a79a1dee0" -dependencies = [ - "async-h1", - "async-session", - "async-sse", - "async-std", - "async-trait", - "femme", - "futures-util", - "http-client", - "http-types", - "kv-log-macro", - "log", - "pin-project-lite 0.2.7", - "route-recognizer", - "serde", - "serde_json", -] - -[[package]] -name = "tide-tracing" -version = "0.0.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9737dbee8b322744e5c0fb4d7baf1e1fae332056cbc1f8a356162a6211b853f4" -dependencies = [ - "async-trait", - "tide", - "tracing", - "tracing-futures", -] - -[[package]] -name = "time" -version = "0.1.43" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" -dependencies = [ - "libc", - "winapi", -] - [[package]] name = "time" version = "0.2.27" @@ -2273,18 +1925,88 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" +[[package]] +name = "tokio" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b7b349f11a7047e6d1276853e612d152f5e8a352c61917887cc2169e2366b4c" +dependencies = [ + "autocfg", + "bytes", + "libc", + "memchr", + "mio", + "num_cpus", + "once_cell", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "winapi", +] + +[[package]] +name = "tokio-rustls" +version = "0.22.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" +dependencies = [ + "rustls", + "tokio", + "webpki", +] + +[[package]] +name = "tokio-stream" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f" +dependencies = [ + "futures-core", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.6.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1caa0b0c8d94a049db56b5acf8cba99dc0623aab1b26d5b5f5e2d945846b3592" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + [[package]] name = "tracing" version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09adeb8c97449311ccd28a427f96fb563e7fd31aabf994189879d9da2394b89d" dependencies = [ - "cfg-if 1.0.0", - "pin-project-lite 0.2.7", + "cfg-if", + "pin-project-lite", "tracing-attributes", "tracing-core", ] +[[package]] +name = "tracing-actix-web" +version = "0.4.0-beta.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c794ee03ca18c0d149e6928db480700644ab405f553f55dc0650f541e73dc180" +dependencies = [ + "actix-web", + "futures", + "opentelemetry", + "tracing", + "tracing-futures", + "tracing-opentelemetry", + "uuid", +] + [[package]] name = "tracing-attributes" version = "0.1.15" @@ -2392,6 +2114,12 @@ version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "879f6906492a7cd215bfa4cf595b600146ccfac0c79bcbd1f3000162af5e8b06" +[[package]] +name = "ucd-trie" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56dee185309b50d1f11bfedef0fe6d036842e3fb77413abef29f8f8d1c5d4c1c" + [[package]] name = "unicode-bidi" version = "0.3.5" @@ -2428,16 +2156,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "39ec24b3121d976906ece63c9daad25b85969647682eee313cb5779fdd69e14e" -[[package]] -name = "universal-hash" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f214e8f697e925001e66ec2c6e37a4ef93f0f78c2eed7814394e10c62025b05" -dependencies = [ - "generic-array", - "subtle", -] - [[package]] name = "untrusted" version = "0.7.1" @@ -2454,18 +2172,15 @@ dependencies = [ "idna", "matches", "percent-encoding", - "serde", ] [[package]] -name = "value-bag" -version = "1.0.0-alpha.7" +name = "uuid" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd320e1520f94261153e96f7534476ad869c14022aee1e59af7c778075d840ae" +checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7" dependencies = [ - "ctor", - "sval", - "version_check", + "getrandom", ] [[package]] @@ -2474,18 +2189,6 @@ version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5fecdca9a5291cc2b8dcf7dc02453fee791a280f3743cb0905f8822ae463b3fe" -[[package]] -name = "waker-fn" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" - -[[package]] -name = "wasi" -version = "0.9.0+wasi-snapshot-preview1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" - [[package]] name = "wasi" version = "0.10.2+wasi-snapshot-preview1" @@ -2498,9 +2201,7 @@ version = "0.2.74" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d54ee1d4ed486f78874278e63e4069fc1ab9f6a18ca492076ffb90c5eb2997fd" dependencies = [ - "cfg-if 1.0.0", - "serde", - "serde_json", + "cfg-if", "wasm-bindgen-macro", ] @@ -2519,18 +2220,6 @@ dependencies = [ "wasm-bindgen-shared", ] -[[package]] -name = "wasm-bindgen-futures" -version = "0.4.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fba7978c679d53ce2d0ac80c8c175840feb849a161664365d1287b41f2e67f1" -dependencies = [ - "cfg-if 1.0.0", - "js-sys", - "wasm-bindgen", - "web-sys", -] - [[package]] name = "wasm-bindgen-macro" version = "0.2.74" @@ -2589,15 +2278,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "wepoll-ffi" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d743fdedc5c64377b5fc2bc036b01c7fd642205a0d96356034ae3404d49eb7fb" -dependencies = [ - "cc", -] - [[package]] name = "whoami" version = "1.1.2" @@ -2635,3 +2315,32 @@ name = "wyz" version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" + +[[package]] +name = "zstd" +version = "0.7.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9428752481d8372e15b1bf779ea518a179ad6c771cca2d2c60e4fbff3cc2cd52" +dependencies = [ + "zstd-safe", +] + +[[package]] +name = "zstd-safe" +version = "3.1.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aa1926623ad7fe406e090555387daf73db555b948134b4d73eac5eb08fb666d" +dependencies = [ + "libc", + "zstd-sys", +] + +[[package]] +name = "zstd-sys" +version = "1.5.0+zstd.1.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e6c094340240369025fc6b731b054ee2a834328fa584310ac96aa4baebdc465" +dependencies = [ + "cc", + "libc", +] diff --git a/Cargo.toml b/Cargo.toml index 39800a4..f6c6598 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,8 +13,7 @@ tracing-subscriber = "0.2" tracing-unwrap = "0.9" tracing-opentelemetry = "0.14" -opentelemetry = { version = "0.15", features = ["rt-async-std"] } -opentelemetry-semantic-conventions = "0.7.0" +opentelemetry = { version = "0.15", features = ["rt-tokio"] } opentelemetry-jaeger = "0.14" lazy_static = "1" @@ -24,14 +23,16 @@ bk-tree = "0.4.0" hamming = "0.1" futures = "0.3" -async-std = { version = "1", features = ["attributes"] } +tokio = { version = "1", features = ["sync"] } serde = { version = "1", features = ["derive"] } serde_json = "1" -tide = "0.16" -tide-tracing = "0.0.11" +actix-web = "4.0.0-beta.8" +actix-http = "3.0.0-beta.8" +actix-service = "2" +tracing-actix-web = { version = "0.4.0-beta.9", features = ["opentelemetry_0_15"] } [dependencies.sqlx] version = "0.5" -features = ["runtime-async-std-rustls", "postgres"] +features = ["runtime-actix-rustls", "postgres"] diff --git a/src/main.rs b/src/main.rs index 0f52225..8651ac1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,17 +1,20 @@ use std::sync::Arc; -use async_std::sync::{RwLock, RwLockUpgradableReadGuard}; +use actix_service::Service; +use actix_web::{ + get, + web::{self, Data}, + App, HttpResponse, HttpServer, Responder, +}; use envconfig::Envconfig; use opentelemetry::KeyValue; -use sqlx::{ - postgres::{PgListener, PgPoolOptions}, - Pool, Postgres, Row, -}; -use tide::Request; +use prometheus::{Encoder, TextEncoder}; +use sqlx::postgres::PgPoolOptions; +use tokio::sync::RwLock; use tracing_subscriber::layer::SubscriberExt; use tracing_unwrap::ResultExt; -mod middlewares; +mod tree; lazy_static::lazy_static! { static ref HTTP_REQUEST_COUNT: prometheus::CounterVec = prometheus::register_counter_vec!("http_requests_total", "Number of HTTP requests", &["http_route", "http_method", "http_status_code"]).unwrap(); @@ -31,8 +34,6 @@ enum Error { Data(serde_json::Error), } -type Tree = Arc>>; - #[derive(Envconfig, Clone)] struct Config { #[envconfig(default = "0.0.0.0:3000")] @@ -51,40 +52,84 @@ struct Config { max_distance: Option, } -/// A hamming distance metric. -struct Hamming; - -impl bk_tree::Metric for Hamming { - fn distance(&self, a: &Node, b: &Node) -> u32 { - hamming::distance_fast(&a.0, &b.0).expect_or_log("hashes did not have same byte alignment") - as u32 - } - - fn threshold_distance(&self, a: &Node, b: &Node, _threshold: u32) -> Option { - Some(self.distance(a, b)) - } -} - -/// A value of a node in the BK tree. -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -struct Node([u8; 8]); - -impl From for Node { - fn from(num: i64) -> Self { - Self(num.to_be_bytes()) - } -} - -impl From for i64 { - fn from(node: Node) -> Self { - i64::from_be_bytes(node.0) - } -} - -#[async_std::main] +#[actix_web::main] async fn main() { let config = Config::init_from_env().expect("could not load config"); + configure_tracing(&config); + tracing::info!("starting bkbase"); + + let tree: tree::Tree = Arc::new(RwLock::new(bk_tree::BKTree::new(tree::Hamming))); + + tracing::trace!("connecting to postgres"); + let pool = PgPoolOptions::new() + .max_connections(2) + .connect(&config.database_url) + .await + .expect_or_log("could not connect to database"); + tracing::debug!("connected to postgres"); + + let http_listen = config.http_listen.clone(); + + let (sender, receiver) = futures::channel::oneshot::channel(); + + tracing::info!("starting to listen for payloads"); + let tree_clone = tree.clone(); + let config_clone = config.clone(); + tokio::task::spawn(async { + tree::listen_for_payloads(pool, config_clone, tree_clone, sender) + .await + .expect_or_log("listenting for updates failed"); + }); + + tracing::info!("waiting for initial tree to load"); + receiver + .await + .expect_or_log("tree loading was dropped before completing"); + tracing::info!("initial tree loaded, starting server"); + + let tree = Data::new(tree); + let config = Data::new(config); + + HttpServer::new(move || { + App::new() + .wrap(tracing_actix_web::TracingLogger::default()) + .wrap_fn(|req, srv| { + let path = req.path().to_owned(); + let method = req.method().to_string(); + + let start = std::time::Instant::now(); + let fut = srv.call(req); + + async move { + let res = fut.await?; + let end = std::time::Instant::now().duration_since(start); + + let status_code = res.status().as_u16().to_string(); + + let labels: Vec<&str> = vec![&path, &method, &status_code]; + HTTP_REQUEST_COUNT.with_label_values(&labels).inc(); + HTTP_REQUEST_DURATION + .with_label_values(&labels) + .observe(end.as_secs_f64()); + + Ok(res) + } + }) + .app_data(tree.clone()) + .app_data(config.clone()) + .service(search) + .service(health) + .service(metrics) + }) + .bind(&http_listen) + .expect_or_log("bind failed") + .run() + .await + .expect_or_log("server failed"); +} + +fn configure_tracing(config: &Config) { opentelemetry::global::set_text_map_propagator(opentelemetry_jaeger::Propagator::new()); let env = std::env::var("ENVIRONMENT"); @@ -103,10 +148,10 @@ async fn main() { KeyValue::new("environment", env.to_owned()), KeyValue::new("version", env!("CARGO_PKG_VERSION")), ]) - .install_batch(opentelemetry::runtime::AsyncStd) + .install_batch(opentelemetry::runtime::Tokio) .expect("otel jaeger pipeline could not be created"); - let trace = tracing_opentelemetry::layer().with_tracer(tracer.clone()); + let trace = tracing_opentelemetry::layer().with_tracer(tracer); tracing::subscriber::set_global_default( tracing_subscriber::Registry::default() .with(tracing_subscriber::EnvFilter::from_default_env()) @@ -114,59 +159,15 @@ async fn main() { .with(tracing_subscriber::fmt::layer()), ) .expect("tracing could not be configured"); - - tracing::info!("starting bkbase"); - - tracing::debug!("loaded config"); - - let tree: Tree = Arc::new(RwLock::new(bk_tree::BKTree::new(Hamming))); - - let pool = PgPoolOptions::new() - .max_connections(2) - .connect(&config.database_url) - .await - .expect_or_log("could not connect to database"); - tracing::debug!("connected to postgres"); - - let http_listen = config.http_listen.clone(); - let max_distance = config.max_distance; - - let (sender, receiver) = futures::channel::oneshot::channel(); - - tracing::info!("starting to listen for payloads"); - let tree_clone = tree.clone(); - async_std::task::spawn(async { - listen_for_payloads(pool, config, tree_clone, sender) - .await - .expect_or_log("listenting for updates failed"); - }); - - tracing::info!("waiting for initial tree to load"); - receiver - .await - .expect_or_log("tree loading was dropped before completing"); - tracing::info!("initial tree loaded, starting server"); - - let mut app = tide::with_state(State { tree, max_distance }); - app.with(middlewares::TideOpentelemMiddleware::new(tracer)); - app.with(tide_tracing::TraceMiddleware::new()); - app.with(middlewares::TidePrometheusMiddleware); - - app.at("/search").get(search); - app.at("/health").get(|_| async { Ok("OK") }); - - app.listen(&http_listen) - .await - .expect_or_log("could not start web server"); } #[derive(Clone)] struct State { - tree: Tree, + tree: tree::Tree, max_distance: Option, } -#[derive(serde::Deserialize)] +#[derive(Debug, serde::Deserialize)] struct Query { hash: i64, distance: u32, @@ -186,21 +187,23 @@ struct SearchResponse { hashes: Vec, } -#[tracing::instrument(skip(req))] -async fn search(req: Request) -> tide::Result { - let state = req.state(); +#[get("/search")] +#[tracing::instrument(skip(query, tree, config), fields(query = ?query.0))] +async fn search( + query: web::Query, + tree: Data, + config: Data, +) -> Result { + let Query { hash, distance } = query.0; + let max_distance = config.max_distance; - let Query { hash, distance } = req.query()?; tracing::info!("searching for hash {} with distance {}", hash, distance); - if matches!(state.max_distance, Some(max_distance) if distance > max_distance) { - return Err(tide::Error::from_str( - 400, - "Distance is greater than max distance", - )); + if matches!(max_distance, Some(max_distance) if distance > max_distance) { + return Ok(HttpResponse::BadRequest().body("distance is greater than max distance")); } - let tree = state.tree.read().await; + let tree = tree.read().await; let duration = TREE_DURATION .with_label_values(&[&distance.to_string()]) @@ -223,113 +226,21 @@ async fn search(req: Request) -> tide::Result { hashes: matches, }; - Ok(serde_json::to_string(&resp)?.into()) + Ok(HttpResponse::Ok().json(resp)) } -/// Create a new BK tree and pull in all hashes from provided query. -/// -/// This must be called after you have started a listener, otherwise items may -/// be lost. -async fn create_tree( - conn: &Pool, - config: &Config, -) -> Result, Error> { - use futures::TryStreamExt; - - tracing::warn!("creating new tree"); - - let mut tree = bk_tree::BKTree::new(Hamming); - - let mut rows = sqlx::query(&config.database_query).fetch(conn); - - let mut count = 0; - - let start = std::time::Instant::now(); - - while let Some(row) = rows.try_next().await.map_err(Error::LoadingRow)? { - let node: Node = row.get::(0).into(); - - // Avoid checking if each value is unique if we were told that the - // database query only returns unique values. - let timer = TREE_ADD_DURATION.start_timer(); - if config.database_is_unique || tree.find_exact(&node).is_none() { - tree.add(node); - } - timer.stop_and_record(); - - count += 1; - if count % 250_000 == 0 { - tracing::debug!(count, "loaded more rows"); - } - } - - let dur = std::time::Instant::now().duration_since(start); - - tracing::info!(count, "completed loading rows in {:?}", dur); - - Ok(tree) +#[get("/health")] +async fn health() -> impl Responder { + "OK" } -#[derive(serde::Deserialize)] -struct Payload { - hash: i64, -} - -/// Listen for incoming payloads. -/// -/// This will create a new tree to ensure all items are present. It will also -/// automatically recreate trees as needed if the database connection is lost. -async fn listen_for_payloads( - conn: Pool, - config: Config, - tree: Tree, - initial: futures::channel::oneshot::Sender<()>, -) -> Result<(), Error> { - let mut listener = PgListener::connect_with(&conn) - .await - .map_err(Error::Listener)?; - listener - .listen(&config.database_subscribe) - .await - .map_err(Error::Listener)?; - - let new_tree = create_tree(&conn, &config).await?; - { - let mut tree = tree.write().await; - *tree = new_tree; - } - - initial - .send(()) - .expect_or_log("nothing listening for initial data"); - - loop { - while let Some(notification) = listener.try_recv().await.map_err(Error::Listener)? { - let payload: Payload = - serde_json::from_str(notification.payload()).map_err(Error::Data)?; - tracing::debug!(hash = payload.hash, "evaluating new payload"); - - let node: Node = payload.hash.into(); - - let _timer = TREE_ADD_DURATION.start_timer(); - - let tree = tree.upgradable_read().await; - if tree.find_exact(&node).is_some() { - tracing::trace!("hash already existed in tree"); - continue; - } - - tracing::trace!("hash did not exist, adding to tree"); - let mut tree = RwLockUpgradableReadGuard::upgrade(tree).await; - tree.add(node); - } - - tracing::error!("disconnected from listener, recreating tree"); - async_std::task::sleep(std::time::Duration::from_secs(10)).await; - let new_tree = create_tree(&conn, &config).await?; - { - let mut tree = tree.write().await; - *tree = new_tree; - } - } +#[get("/metrics")] +async fn metrics() -> Result { + let mut buffer = Vec::new(); + let encoder = TextEncoder::new(); + + let metric_families = prometheus::gather(); + encoder.encode(&metric_families, &mut buffer).unwrap(); + + Ok(HttpResponse::Ok().body(buffer)) } diff --git a/src/middlewares.rs b/src/middlewares.rs deleted file mode 100644 index 2c96181..0000000 --- a/src/middlewares.rs +++ /dev/null @@ -1,139 +0,0 @@ -use std::collections::HashMap; -use std::convert::TryFrom; - -use opentelemetry::{ - global::get_text_map_propagator, - trace::{FutureExt, Span, SpanKind, TraceContextExt, Tracer}, - Context, -}; -use opentelemetry_semantic_conventions::trace; -use prometheus::{Encoder, TextEncoder}; -use tide::{ - http::{ - headers::{HeaderName, HeaderValue}, - mime, - }, - Middleware, Request, Response, -}; - -pub struct TidePrometheusMiddleware; - -impl TidePrometheusMiddleware { - const ROUTE: &'static str = "/metrics"; -} - -#[tide::utils::async_trait] -impl Middleware for TidePrometheusMiddleware { - async fn handle(&self, req: Request, next: tide::Next<'_, State>) -> tide::Result { - let path = req.url().path().to_owned(); - - if path == Self::ROUTE { - let mut buffer = Vec::new(); - let encoder = TextEncoder::new(); - - let metric_families = prometheus::gather(); - encoder.encode(&metric_families, &mut buffer).unwrap(); - - return Ok(Response::builder(200) - .body(buffer) - .content_type(mime::PLAIN) - .build()); - } - - let method = req.method().to_string(); - - let start = std::time::Instant::now(); - let res = next.run(req).await; - let end = std::time::Instant::now().duration_since(start); - - let status_code = res.status().to_string(); - - let labels: Vec<&str> = vec![&path, &method, &status_code]; - - crate::HTTP_REQUEST_COUNT.with_label_values(&labels).inc(); - crate::HTTP_REQUEST_DURATION - .with_label_values(&labels) - .observe(end.as_secs_f64()); - - Ok(res) - } -} - -pub struct TideOpentelemMiddleware { - tracer: T, -} - -impl TideOpentelemMiddleware { - pub fn new(tracer: T) -> Self { - Self { tracer } - } -} - -#[tide::utils::async_trait] -impl Middleware - for TideOpentelemMiddleware -{ - async fn handle(&self, req: Request, next: tide::Next<'_, State>) -> tide::Result { - let parent_cx = get_parent_cx(&req); - - let method = req.method().to_string(); - let url = req.url(); - - let attributes = vec![ - trace::HTTP_METHOD.string(method.clone()), - trace::HTTP_SCHEME.string(url.scheme().to_string()), - trace::HTTP_URL.string(url.to_string()), - ]; - - let mut span_builder = self - .tracer - .span_builder(format!("{} {}", method, url.path())) - .with_kind(SpanKind::Server) - .with_attributes(attributes); - - if parent_cx.span().span_context().is_remote() { - tracing::trace!("incoming request has remote span: {:?}", parent_cx); - span_builder = span_builder.with_parent_context(parent_cx); - } - - let mut span = span_builder.start(&self.tracer); - span.add_event("request.started".to_owned(), vec![]); - let cx = &Context::current_with_span(span); - - let mut res = next.run(req).with_context(cx.clone()).await; - - let span = cx.span(); - span.add_event("request.completed".to_owned(), vec![]); - span.set_attribute(trace::HTTP_STATUS_CODE.i64(u16::from(res.status()).into())); - - if let Some(len) = res.len().and_then(|len| i64::try_from(len).ok()) { - span.set_attribute(trace::HTTP_RESPONSE_CONTENT_LENGTH.i64(len)); - } - - let mut injector = HashMap::new(); - get_text_map_propagator(|propagator| propagator.inject_context(&cx, &mut injector)); - - for (key, value) in injector { - let header_name = HeaderName::from_bytes(key.into_bytes()); - let header_value = HeaderValue::from_bytes(value.into_bytes()); - - if let (Ok(name), Ok(value)) = (header_name, header_value) { - res.insert_header(name, value); - } else { - tracing::error!("injected header data was invalid"); - } - } - - Ok(res) - } -} - -fn get_parent_cx(req: &Request) -> Context { - let mut req_headers = HashMap::new(); - - for (key, value) in req.iter() { - req_headers.insert(key.to_string(), value.last().to_string()); - } - - get_text_map_propagator(|propagator| propagator.extract(&req_headers)) -} diff --git a/src/tree.rs b/src/tree.rs new file mode 100644 index 0000000..530536a --- /dev/null +++ b/src/tree.rs @@ -0,0 +1,143 @@ +use std::sync::Arc; + +use sqlx::{postgres::PgListener, Pool, Postgres, Row}; +use tokio::sync::RwLock; +use tracing_unwrap::ResultExt; + +use crate::{Config, Error}; + +pub(crate) type Tree = Arc>>; + +/// A hamming distance metric. +pub(crate) struct Hamming; + +impl bk_tree::Metric for Hamming { + fn distance(&self, a: &Node, b: &Node) -> u32 { + hamming::distance_fast(&a.0, &b.0).expect_or_log("hashes did not have same byte alignment") + as u32 + } + + fn threshold_distance(&self, a: &Node, b: &Node, _threshold: u32) -> Option { + Some(self.distance(a, b)) + } +} + +/// A value of a node in the BK tree. +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) struct Node([u8; 8]); + +impl From for Node { + fn from(num: i64) -> Self { + Self(num.to_be_bytes()) + } +} + +impl From for i64 { + fn from(node: Node) -> Self { + i64::from_be_bytes(node.0) + } +} + +/// Create a new BK tree and pull in all hashes from provided query. +/// +/// This must be called after you have started a listener, otherwise items may +/// be lost. +async fn create_tree( + conn: &Pool, + config: &Config, +) -> Result, Error> { + use futures::TryStreamExt; + + tracing::warn!("creating new tree"); + let mut tree = bk_tree::BKTree::new(Hamming); + let mut rows = sqlx::query(&config.database_query).fetch(conn); + + let mut count = 0; + + let start = std::time::Instant::now(); + + while let Some(row) = rows.try_next().await.map_err(Error::LoadingRow)? { + let node: Node = row.get::(0).into(); + + // Avoid checking if each value is unique if we were told that the + // database query only returns unique values. + let timer = crate::TREE_ADD_DURATION.start_timer(); + if config.database_is_unique || tree.find_exact(&node).is_none() { + tree.add(node); + } + timer.stop_and_record(); + + count += 1; + if count % 250_000 == 0 { + tracing::debug!(count, "loaded more rows"); + } + } + + let dur = std::time::Instant::now().duration_since(start); + + tracing::info!(count, "completed loading rows in {:?}", dur); + Ok(tree) +} + +#[derive(serde::Deserialize)] +struct Payload { + hash: i64, +} + +/// Listen for incoming payloads. +/// +/// This will create a new tree to ensure all items are present. It will also +/// automatically recreate trees as needed if the database connection is lost. +pub(crate) async fn listen_for_payloads( + conn: Pool, + config: Config, + tree: Tree, + initial: futures::channel::oneshot::Sender<()>, +) -> Result<(), Error> { + let mut listener = PgListener::connect_with(&conn) + .await + .map_err(Error::Listener)?; + listener + .listen(&config.database_subscribe) + .await + .map_err(Error::Listener)?; + + let new_tree = create_tree(&conn, &config).await?; + { + let mut tree = tree.write().await; + *tree = new_tree; + } + + initial + .send(()) + .expect_or_log("nothing listening for initial data"); + + loop { + while let Some(notification) = listener.try_recv().await.map_err(Error::Listener)? { + let payload: Payload = + serde_json::from_str(notification.payload()).map_err(Error::Data)?; + tracing::debug!(hash = payload.hash, "evaluating new payload"); + + let node: Node = payload.hash.into(); + + let _timer = crate::TREE_ADD_DURATION.start_timer(); + + let mut tree = tree.write().await; + if tree.find_exact(&node).is_some() { + tracing::trace!("hash already existed in tree"); + continue; + } + + tracing::trace!("hash did not exist, adding to tree"); + tree.add(node); + } + + tracing::error!("disconnected from listener, recreating tree"); + tokio::time::sleep(std::time::Duration::from_secs(10)).await; + let new_tree = create_tree(&conn, &config).await?; + { + let mut tree = tree.write().await; + *tree = new_tree; + } + } +}