diff --git a/Cargo.lock b/Cargo.lock index 399b0387e..9c3988d17 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,10 +1,274 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. [[package]] -name = "ahash" -version = "0.3.2" +name = "actix-codec" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0989268a37e128d4d7a8028f1c60099430113fdbc70419010601ce51a228e4fe" +checksum = "09e55f0a5c2ca15795035d90c46bd0e73a5123b72f68f12596d6ba5282051380" +dependencies = [ + "bitflags", + "bytes 0.5.4", + "futures-core", + "futures-sink", + "log", + "tokio", + "tokio-util 0.2.0", +] + +[[package]] +name = "actix-connect" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c95cc9569221e9802bf4c377f6c18b90ef10227d787611decf79fd47d2a8e76c" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "derive_more", + "either", + "futures", + "http 0.2.1", + "log", + "trust-dns-proto", + "trust-dns-resolver", +] + +[[package]] +name = "actix-http" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c16664cc4fdea8030837ad5a845eb231fb93fc3c5c171edfefb52fad92ce9019" +dependencies = [ + "actix-codec", + "actix-connect", + "actix-rt", + "actix-service", + "actix-threadpool", + "actix-utils", + "base64 0.11.0", + "bitflags", + "brotli2", + "bytes 0.5.4", + "chrono", + "copyless", + "derive_more", + "either", + "encoding_rs", + "failure", + "flate2", + "futures-channel", + "futures-core", + "futures-util", + "fxhash", + "h2", + "http 0.2.1", + "httparse", + "indexmap", + "language-tags", + "lazy_static", + "log", + "mime", + "percent-encoding 2.1.0", + "pin-project", + "rand 0.7.3", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "sha1", + "slab", + "time", +] + +[[package]] +name = "actix-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21705adc76bbe4bc98434890e73a89cd00c6015e5704a60bb6eea6c3b72316b6" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "actix-router" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d7a10ca4d94e8c8e7a87c5173aba1b97ba9a6563ca02b0e1cd23531093d3ec8" +dependencies = [ + "bytestring", + "http 0.2.1", + "log", + "regex", + "serde", +] + +[[package]] +name = "actix-rt" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20066d9200ef8d441ac156c76dd36c3f1e9a15976c34e69ae97f7f570b331882" +dependencies = [ + "actix-macros", + "actix-threadpool", + "copyless", + "futures-channel", + "futures-util", + "tokio", +] + +[[package]] +name = "actix-server" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "582a7173c281a4f46b5aa168a11e7f37183dcb71177a39312cc2264da7a632c9" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "futures", + "log", + "mio", + "mio-uds", + "net2", + "num_cpus", + "slab", +] + +[[package]] +name = "actix-service" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3e4fc95dfa7e24171b2d0bb46b85f8ab0e8499e4e3caec691fc4ea65c287564" +dependencies = [ + "futures-util", + "pin-project", +] + +[[package]] +name = "actix-testing" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48494745b72d0ea8ff0cf874aaf9b622a3ee03d7081ee0c04edea4f26d32c911" +dependencies = [ + "actix-macros", + "actix-rt", + "actix-server", + "actix-service", + "futures", + "log", + "net2", +] + +[[package]] +name = "actix-threadpool" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf4082192601de5f303013709ff84d81ca6a1bc4af7fb24f367a500a23c6e84e" +dependencies = [ + "derive_more", + "futures-channel", + "lazy_static", + "log", + "num_cpus", + "parking_lot", + "threadpool", +] + +[[package]] +name = "actix-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4e5b4faaf105e9a6d389c606c298dcdb033061b00d532af9df56ff3a54995a8" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "actix-utils", + "derive_more", + "either", + "futures", + "log", +] + +[[package]] +name = "actix-utils" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf8f5631bf01adec2267808f00e228b761c60c0584cc9fa0b5364f41d147f4e" +dependencies = [ + "actix-codec", + "actix-rt", + "actix-service", + "bitflags", + "bytes 0.5.4", + "either", + "futures", + "log", + "pin-project", + "slab", +] + +[[package]] +name = "actix-web" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3158e822461040822f0dbf1735b9c2ce1f95f93b651d7a7aded00b1efbb1f635" +dependencies = [ + "actix-codec", + "actix-http", + "actix-macros", + "actix-router", + "actix-rt", + "actix-server", + "actix-service", + "actix-testing", + "actix-threadpool", + "actix-tls", + "actix-utils", + "actix-web-codegen", + "awc", + "bytes 0.5.4", + "derive_more", + "encoding_rs", + "futures", + "fxhash", + "log", + "mime", + "net2", + "pin-project", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "time", + "url", +] + +[[package]] +name = "actix-web-codegen" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f00371942083469785f7e28c540164af1913ee7c96a4534acb9cea92c39f057" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "adler32" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d2e7343e7fc9de883d1b0341e0b13970f764c14101234857d2ddafa1cb1cac2" + +[[package]] +name = "ahash" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35b909d1c126f78ace756fc337133356c499eebeefcce930fa5fb018823f2b2d" dependencies = [ "const-random", ] @@ -29,9 +293,9 @@ dependencies = [ [[package]] name = "arc-swap" -version = "0.4.5" +version = "0.4.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d663a8e9a99154b5fb793032533f6328da35e23aac63d5c152279aa8ba356825" +checksum = "b585a98a234c46fc563103e9278c9391fde1f4e6850334da895d27edb9580f62" [[package]] name = "assert-json-diff" @@ -48,37 +312,16 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7deb0a829ca7bcfaf5da70b073a8d128619259a7be8216a355e23f00763059e5" -[[package]] -name = "async-attributes" -version = "1.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "efd3d156917d94862e779f356c5acae312b08fd3121e792c857d7928c8088423" -dependencies = [ - "quote", - "syn", -] - [[package]] name = "async-std" version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "538ecb01eb64eecd772087e5b6f7540cbc917f047727339a472dafed2185b267" dependencies = [ - "async-attributes", - "async-task", - "broadcaster", - "crossbeam-channel", - "crossbeam-deque", "crossbeam-utils", "futures-core", "futures-io", - "futures-timer", - "kv-log-macro", - "log", "memchr", - "mio", - "mio-uds", - "num_cpus", "once_cell", "pin-project-lite", "pin-utils", @@ -86,13 +329,14 @@ dependencies = [ ] [[package]] -name = "async-task" -version = "1.3.1" +name = "async-trait" +version = "0.1.30" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ac2c016b079e771204030951c366db398864f5026f84a44dafb0ff20f02085d" +checksum = "da71fef07bc806586090247e971229289f64c210a278ee5ae419314eb386b31d" dependencies = [ - "libc", - "winapi 0.3.8", + "proc-macro2", + "quote", + "syn", ] [[package]] @@ -112,6 +356,29 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9d" +[[package]] +name = "awc" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7601d4d1d7ef2335d6597a41b5fe069f6ab799b85f53565ab390e7b7065aac5" +dependencies = [ + "actix-codec", + "actix-http", + "actix-rt", + "actix-service", + "base64 0.11.0", + "bytes 0.5.4", + "derive_more", + "futures-core", + "log", + "mime", + "percent-encoding 2.1.0", + "rand 0.7.3", + "serde", + "serde_json", + "serde_urlencoded", +] + [[package]] name = "backtrace" version = "0.3.46" @@ -126,9 +393,9 @@ dependencies = [ [[package]] name = "backtrace-sys" -version = "0.1.35" +version = "0.1.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8aba10a69c8e8d7622c5710229485ec32e9d55fdad160ea559c086fdcd118" +checksum = "78848718ee1255a2485d1309ad9cdecfc2e7d0362dd11c6829364c6b35ae1bc7" dependencies = [ "cc", "libc", @@ -184,17 +451,23 @@ dependencies = [ ] [[package]] -name = "broadcaster" -version = "1.0.0" +name = "brotli-sys" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9c972e21e0d055a36cf73e4daae870941fe7a8abcd5ac3396aab9e4c126bd87" +checksum = "4445dea95f4c2b41cde57cc9fee236ae4dbae88d8fcbdb4750fc1bb5d86aaecd" dependencies = [ - "futures-channel", - "futures-core", - "futures-sink", - "futures-util", - "parking_lot 0.10.0", - "slab", + "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]] @@ -234,10 +507,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "206fdffcfa2df7cbe15601ef46c813fce0965eb3286db6b56c583b814b51c81c" dependencies = [ "byteorder", - "either", "iovec", ] +[[package]] +name = "bytes" +version = "0.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1" + +[[package]] +name = "bytestring" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7c05fa5172da78a62d9949d662d2ac89d4cc7355d7b49adee5163f1fb3f363" +dependencies = [ + "bytes 0.5.4", +] + [[package]] name = "cast" version = "0.2.3" @@ -249,9 +536,9 @@ dependencies = [ [[package]] name = "cc" -version = "1.0.50" +version = "1.0.52" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd" +checksum = "c3d87b23d6a92cd03af510a5ade527033f6aa6fa92161e2d5863a907d4c5e31d" [[package]] name = "cfg-if" @@ -273,9 +560,9 @@ dependencies = [ [[package]] name = "chunked_transfer" -version = "1.0.0" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f98beb6554de08a14bd7b5c6014963c79d6a25a1c66b1d4ecb9e733ccba51d6c" +checksum = "5b89647f09b9f4c838cb622799b2843e4e13bff64661dab9a0362bb92985addd" [[package]] name = "clap" @@ -328,13 +615,18 @@ dependencies = [ ] [[package]] -name = "cookie" -version = "0.12.0" +name = "copyless" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "888604f00b3db336d2af898ec3c1d5d0ddf5e6d462220f2ededc33a87ac4bbd5" +checksum = "6ff9c56c9fb2a49c05ef0e431485a22400af20d33226dc0764d891d09e724127" + +[[package]] +name = "crc32fast" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba125de2af0df55319f41944744ad91c71113bf74a4646efff39afe1f6842db1" dependencies = [ - "time", - "url 1.7.2", + "cfg-if", ] [[package]] @@ -458,10 +750,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11c0346158a19b3627234e15596f5e465c360fcdb97d817bcb255e0510f5a788" [[package]] -name = "deunicode" -version = "1.1.0" +name = "derive_more" +version = "0.99.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "307dde1a517939465bc4042b47377284a56cee6160f8066f1f5035eb7b25a3fc" +checksum = "e2323f3f47db9a0e77ce7a300605d8d2098597fc451ed1a97bb1f6411bb550a7" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "deunicode" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80115a2dfde04491e181c2440a39e4be26e52d9ca4e92bed213f65b94e0b8db1" [[package]] name = "digest" @@ -478,12 +781,39 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fea41bba32d969b513997752735605054bc0dfa92b4c56bf1189f2e174be7a10" +[[package]] +name = "dtoa" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4358a9e11b9a09cf52383b451b49a169e8d797b68aa02301ff586d70d9661ea3" + [[package]] name = "either" version = "1.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bb1f6b1ce1c140482ea30ddd3335fc0024ac7ee112895426e0a629a6c20adfe3" +[[package]] +name = "encoding_rs" +version = "0.8.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd8d03faa7fe0c1431609dfad7bbe827af30f82e1e2ae6f7ee4fca6bd764bc28" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "enum-as-inner" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc4bfcfacb61d231109d1d55202c1f33263319668b168843e02ad4652725ec9c" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "env_logger" version = "0.7.1" @@ -507,12 +837,46 @@ dependencies = [ "version_check", ] +[[package]] +name = "failure" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8529c2421efa3066a5cbd8063d2244603824daccb6936b079010bb2aa89464b" +dependencies = [ + "backtrace", + "failure_derive", +] + +[[package]] +name = "failure_derive" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "030a733c8287d6213886dd487564ff5c8f6aae10278b3588ed177f9d18f8d231" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + [[package]] name = "fake-simd" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" +[[package]] +name = "flate2" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cfff41391129e0a856d6d822600b8d71179d46879e310417eb9c762eb178b42" +dependencies = [ + "cfg-if", + "crc32fast", + "libc", + "miniz_oxide", +] + [[package]] name = "fnv" version = "1.0.6" @@ -556,12 +920,6 @@ version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" -[[package]] -name = "futures" -version = "0.1.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b980f2816d6ee8673b6517b52cb0e808a180efc92e5c19d02cdda79066703ef" - [[package]] name = "futures" version = "0.3.4" @@ -593,16 +951,6 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f25592f769825e89b92358db00d26f965761e094951ac44d3663ef25b7ac464a" -[[package]] -name = "futures-cpupool" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" -dependencies = [ - "futures 0.1.29", - "num_cpus", -] - [[package]] name = "futures-executor" version = "0.3.4" @@ -644,19 +992,12 @@ version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7b0a34e53cf6cdcd0178aa573aed466b646eb3db769570841fda0c7ede375a27" -[[package]] -name = "futures-timer" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1de7508b218029b0f01662ed8f61b1c964b3ae99d6f25462d0f55a595109df6" - [[package]] name = "futures-util" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22766cf25d64306bedf0384da004d05c9974ab104fcc4528f1236181c18004c5" dependencies = [ - "futures 0.1.29", "futures-channel", "futures-core", "futures-io", @@ -668,7 +1009,15 @@ dependencies = [ "proc-macro-hack", "proc-macro-nested", "slab", - "tokio-io", +] + +[[package]] +name = "fxhash" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" +dependencies = [ + "byteorder", ] [[package]] @@ -702,20 +1051,21 @@ dependencies = [ [[package]] name = "h2" -version = "0.1.26" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5b34c246847f938a410a03c5458c7fee2274436675e76d8b903c08efc29c462" +checksum = "377038bf3c89d18d6ca1431e7a5027194fbd724ca10592b9487ede5e8e144f42" dependencies = [ - "byteorder", - "bytes", + "bytes 0.5.4", "fnv", - "futures 0.1.29", - "http", + "futures-core", + "futures-sink", + "futures-util", + "http 0.2.1", "indexmap", "log", "slab", - "string", - "tokio-io", + "tokio", + "tokio-util 0.3.1", ] [[package]] @@ -740,52 +1090,80 @@ dependencies = [ [[package]] name = "heed" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73881598a84bdb0d7bcf40496c1a2a6e10dc06cbb73fb56989b950037bff63c" +checksum = "5d432af60d4dada5bc2d391b98ed258a16e659a4b5ec88b0c90e148062ed1a5c" dependencies = [ - "bincode", "byteorder", + "heed-traits", + "heed-types", "libc", "lmdb-rkv-sys", "once_cell", "page_size", + "url", + "zerocopy", +] + +[[package]] +name = "heed-traits" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b328f6260a7e51bdb0ca6b68e6ea27ee3d11fba5dee930896ee7ff6ad5fc072c" + +[[package]] +name = "heed-types" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e100387815256b00dbb4f48db990f7fa03e9b88b4a89c2a1661b7d9d77b77c46" +dependencies = [ + "bincode", + "heed-traits", "serde", "serde_json", - "url 2.1.1", "zerocopy", ] [[package]] name = "hermit-abi" -version = "0.1.10" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "725cf19794cf90aa94e65050cb4191ff5d8fa87a498383774c47b332e3af952e" +checksum = "61565ff7aaace3525556587bd2dc31d4a07071957be715e63ce7b1eccf51a8f4" dependencies = [ "libc", ] +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi 0.3.8", +] + [[package]] name = "http" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6ccf5ede3a895d8856620237b2f02972c1bbc78d2965ad7fe8838d4a0ed41f0" dependencies = [ - "bytes", + "bytes 0.4.12", "fnv", "itoa", ] [[package]] -name = "http-body" -version = "0.1.0" +name = "http" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" +checksum = "28d569972648b2c512421b5f2a405ad6ac9666547189d0c5477a3f200f3e02f9" dependencies = [ - "bytes", - "futures 0.1.29", - "http", - "tokio-buf", + "bytes 0.5.4", + "fnv", + "itoa", ] [[package]] @@ -795,31 +1173,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9625f605ddfaf894bf78a544a7b8e31f562dc843654723a49892d9c7e75ac708" dependencies = [ "async-std", - "bytes", - "futures 0.3.4", - "http", + "bytes 0.4.12", + "futures", + "http 0.1.21", "pin-project-lite", ] -[[package]] -name = "http-service-hyper" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33d5dae94e0fdb82f9524ea2f2b98458b3d8448526d8cc8beccb3d3fded8aff" -dependencies = [ - "futures 0.3.4", - "http", - "http-service", - "hyper", -] - [[package]] name = "http-service-mock" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "893e67bcfcd552717ddfcc3af17fa5397d39a2b1a64a8266271efff619d6af45" dependencies = [ - "futures 0.3.4", + "futures", "http-service", ] @@ -838,47 +1204,6 @@ dependencies = [ "quick-error", ] -[[package]] -name = "hyper" -version = "0.12.35" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9dbe6ed1438e1f8ad955a4701e9a944938e9519f6888d12d8558b645e247d5f6" -dependencies = [ - "bytes", - "futures 0.1.29", - "futures-cpupool", - "h2", - "http", - "http-body", - "httparse", - "iovec", - "itoa", - "log", - "net2", - "rustc_version", - "time", - "tokio", - "tokio-buf", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "want", -] - -[[package]] -name = "idna" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f09e0f0b1fb55fdee1f17470ad800da77af5186a1a76c026b679358b7e844e" -dependencies = [ - "matches", - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "idna" version = "0.2.0" @@ -906,7 +1231,7 @@ version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8254add2ea664734c9d001f8151cc3d7696b135f7e40e5a2efa814a662cb3a44" dependencies = [ - "smallvec 1.3.0", + "smallvec", ] [[package]] @@ -918,6 +1243,18 @@ dependencies = [ "libc", ] +[[package]] +name = "ipconfig" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa79fa216fbe60834a9c0737d7fcd30425b32d1c58854663e24d4c4b328ed83f" +dependencies = [ + "socket2", + "widestring", + "winapi 0.3.8", + "winreg", +] + [[package]] name = "itertools" version = "0.8.2" @@ -983,13 +1320,10 @@ dependencies = [ ] [[package]] -name = "kv-log-macro" -version = "1.0.4" +name = "language-tags" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c54d9f465d530a752e6ebdc217e081a7a614b48cb200f6f0aee21ba6bc9aabb" -dependencies = [ - "log", -] +checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" [[package]] name = "lazy_static" @@ -1008,9 +1342,15 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.68" +version = "0.2.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dea0c0405123bba743ee3f91f49b1c7cfb684eef0da0a50110f758ccf24cdff0" +checksum = "99e85c08494b21a9054e7fe1374a732aeadaff3980b6990b94bfd3a70f690005" + +[[package]] +name = "linked-hash-map" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae91b68aebc4ddb91978b11a1b02ddd8602a05ec19002801c5666000e05e0f83" [[package]] name = "lmdb-rkv-sys" @@ -1025,9 +1365,9 @@ dependencies = [ [[package]] name = "lock_api" -version = "0.3.3" +version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" +checksum = "c4da24a77a3d8a6d4862d95f72e6fdb9c09a643ecdb402d754004a557f2bec75" dependencies = [ "scopeguard", ] @@ -1041,6 +1381,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "lru-cache" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" +dependencies = [ + "linked-hash-map", +] + [[package]] name = "main_error" version = "0.1.0" @@ -1053,6 +1402,12 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3e2e65a1a2e43cfcb47a895c4c8b10d1f4a61097f9f254f183aee60cad9c651d" +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "matches" version = "0.1.8" @@ -1114,14 +1469,16 @@ dependencies = [ name = "meilisearch-http" version = "0.10.1" dependencies = [ + "actix-http", + "actix-rt", + "actix-web", "assert-json-diff", - "async-std", "chrono", "crossbeam-channel", "env_logger", - "futures 0.3.4", + "futures", "heed", - "http", + "http 0.1.21", "http-service", "http-service-mock", "indexmap", @@ -1145,7 +1502,7 @@ dependencies = [ "structopt", "sysinfo", "tempdir", - "tide", + "tokio", "ureq", "vergen", "walkdir", @@ -1200,6 +1557,15 @@ version = "0.3.16" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" +[[package]] +name = "miniz_oxide" +version = "0.3.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa679ff6578b1cddee93d7e82e263b94a575e0bfced07284eb0c037c1d2416a5" +dependencies = [ + "adler32", +] + [[package]] name = "mio" version = "0.6.21" @@ -1296,9 +1662,9 @@ dependencies = [ [[package]] name = "num_cpus" -version = "1.12.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46203554f085ff89c235cd12f7075f3233af9b11ed7c9e16dfe2560d03313ce6" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" dependencies = [ "hermit-abi", "libc", @@ -1344,51 +1710,25 @@ dependencies = [ [[package]] name = "parking_lot" -version = "0.9.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" +checksum = "d3a704eb390aafdc107b0e392f56a82b668e3a71366993b5340f5833fd62505e" dependencies = [ "lock_api", - "parking_lot_core 0.6.2", - "rustc_version", -] - -[[package]] -name = "parking_lot" -version = "0.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e98c49ab0b7ce5b222f2cc9193fc4efe11c6d0bd4f648e374684a6857b1cfc" -dependencies = [ - "lock_api", - "parking_lot_core 0.7.0", + "parking_lot_core", ] [[package]] name = "parking_lot_core" -version = "0.6.2" +version = "0.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" +checksum = "d58c7c768d4ba344e3e8d72518ac13e259d7c7ade24167003b8488e10b6740a3" dependencies = [ "cfg-if", "cloudabi", "libc", "redox_syscall", - "rustc_version", - "smallvec 0.6.13", - "winapi 0.3.8", -] - -[[package]] -name = "parking_lot_core" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7582838484df45743c8434fbff785e8edf260c28748353d44bc0da32e0ceabf1" -dependencies = [ - "cfg-if", - "cloudabi", - "libc", - "redox_syscall", - "smallvec 1.3.0", + "smallvec", "winapi 0.3.8", ] @@ -1455,6 +1795,26 @@ dependencies = [ "sha-1", ] +[[package]] +name = "pin-project" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f6a7f5eee6292c559c793430c55c00aea9d3b3d1905e855806ca4d7253426a2" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8988430ce790d8682672117bc06dda364c0be32d3abd738234f19f3240bad99a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "pin-project-lite" version = "0.1.4" @@ -1463,9 +1823,9 @@ checksum = "237844750cfbb86f67afe27eee600dfbbcb6188d734139b534cbfbf4f96792ae" [[package]] name = "pin-utils" -version = "0.1.0-alpha.4" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" @@ -1682,9 +2042,9 @@ checksum = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" [[package]] name = "regex" -version = "1.3.6" +version = "1.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f6946991529684867e47d86474e3a6d0c0ab9b82d5821e314b1ede31fa3a4b3" +checksum = "a6020f034922e3194c711b82a627453881bc4682166cabb07134a10c26ba7692" dependencies = [ "aho-corasick", "memchr", @@ -1716,6 +2076,16 @@ dependencies = [ "winapi 0.3.8", ] +[[package]] +name = "resolv-conf" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11834e137f3b14e309437a8276714eed3a80d1ef894869e510f2c0c0b98b9f4a" +dependencies = [ + "hostname", + "quick-error", +] + [[package]] name = "ring" version = "0.16.12" @@ -1731,12 +2101,6 @@ dependencies = [ "winapi 0.3.8", ] -[[package]] -name = "route-recognizer" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea509065eb0b3c446acdd0102f0d46567dc30902dc0be91d6552035d92b0f4f8" - [[package]] name = "rustc-demangle" version = "0.1.16" @@ -1767,15 +2131,16 @@ dependencies = [ [[package]] name = "rustyline" -version = "6.1.0" +version = "6.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6155a1169c281a8b75ee943a83eef0e2bb63aff057688c2111be319e51fc9f63" +checksum = "1cd20b28d972040c627e209eb29f19c24a71a19d661cc5a220089176e20ee202" dependencies = [ "cfg-if", "libc", "log", "memchr", "nix", + "scopeguard", "unicode-segmentation", "unicode-width", "utf8parse", @@ -1784,9 +2149,9 @@ dependencies = [ [[package]] name = "ryu" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "535622e6be132bccd223f4bb2b8ac8d53cda3c7a6394944d3b2b33fb974f9d76" +checksum = "ed3d612bc64430efeb3f7ee6ef26d590dce0c43249217bddc62112540c7941e1" [[package]] name = "same-file" @@ -1878,6 +2243,18 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_urlencoded" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ec5d77e2d4c73717816afac02670d5c4f534ea95ed430442cad02e7a6e32c97" +dependencies = [ + "dtoa", + "itoa", + "serde", + "url", +] + [[package]] name = "sha-1" version = "0.8.2" @@ -1890,6 +2267,12 @@ dependencies = [ "opaque-debug", ] +[[package]] +name = "sha1" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" + [[package]] name = "sha2" version = "0.8.1" @@ -1903,10 +2286,20 @@ dependencies = [ ] [[package]] -name = "siphasher" -version = "0.3.2" +name = "signal-hook-registry" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e88f89a550c01e4cd809f3df4f52dc9e939f3273a2017eabd5c6d12fd98bb23" +checksum = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41" +dependencies = [ + "arc-swap", + "libc", +] + +[[package]] +name = "siphasher" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa8f3741c7372e75519bd9346068370c9cdaabcc1f9599cbcf2a2719352286b7" [[package]] name = "slab" @@ -1922,18 +2315,21 @@ checksum = "1f7474f0b646d228360ab62ed974744617bc869d959eac8403bfa3665931a7fb" [[package]] name = "smallvec" -version = "0.6.13" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6" -dependencies = [ - "maybe-uninit", -] +checksum = "c7cb5678e1615754284ec264d9bb5b4c27d2018577fd90ac0ceb578591ed5ee4" [[package]] -name = "smallvec" -version = "1.3.0" +name = "socket2" +version = "0.3.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05720e22615919e4734f6a99ceae50d00226c3c5aca406e102ebc33298214e0a" +checksum = "03088793f677dce356f3ccc2edb1b314ad191ab702a5de3faf49304f7e104918" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "winapi 0.3.8", +] [[package]] name = "spin" @@ -1941,15 +2337,6 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "string" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24114bfcceb867ca7f71a0d3fe45d45619ec47a6fbfa98cb14e14250bfa5d6d" -dependencies = [ - "bytes", -] - [[package]] name = "strsim" version = "0.8.0" @@ -1958,9 +2345,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.13" +version = "0.3.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff6da2e8d107dfd7b74df5ef4d205c6aebee0706c647f6bc6a2d5789905c00fb" +checksum = "863246aaf5ddd0d6928dfeb1a9ca65f505599e4e1b399935ef7e75107516b4ef" dependencies = [ "clap", "lazy_static", @@ -1969,9 +2356,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.6" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a489c87c08fbaf12e386665109dd13470dcc9c4583ea3e10dd2b4523e5ebd9ac" +checksum = "d239ca4b13aee7a2142e6795cbd69e457665ff8037aed33b3effdc430d2f927a" dependencies = [ "heck", "proc-macro-error", @@ -1982,9 +2369,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.17" +version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0df0eb663f387145cab623dea85b09c2c5b4b0aef44e945d928e682fce71bb03" +checksum = "410a7488c0a728c7ceb4ad59b9567eb4053d02e8cc7f5c0e0eeeb39518369213" dependencies = [ "proc-macro2", "quote", @@ -2081,42 +2468,29 @@ dependencies = [ ] [[package]] -name = "tide" -version = "0.6.0" +name = "threadpool" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e619c99048ae107912703d0efeec4ff4fbff704f064e51d3eee614b28ea7b739" +checksum = "e8dae184447c15d5a6916d973c642aec485105a13cd238192a6927ae3e077d66" dependencies = [ - "async-std", - "cookie", - "futures 0.3.4", - "http", - "http-service", - "http-service-hyper", - "log", - "mime", - "pin-project-lite", - "route-recognizer", - "serde", - "serde_json", - "serde_qs", + "num_cpus", ] [[package]] name = "time" -version = "0.1.42" +version = "0.1.43" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db8dcfca086c1143c9270ac42a2bbd8a7ee477b78ac8e45b19abfb0cbede4b6f" +checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" dependencies = [ "libc", - "redox_syscall", "winapi 0.3.8", ] [[package]] name = "tinytemplate" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57a3c6667d3e65eb1bc3aed6fd14011c6cbc3a0665218ab7f5daf040b9ec371a" +checksum = "45e4bc5ac99433e0dcb8b9f309dd271a165ae37dde129b9e0ce1bfdd8bfe4891" dependencies = [ "serde", "serde_json", @@ -2124,134 +2498,63 @@ dependencies = [ [[package]] name = "tokio" -version = "0.1.22" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes", - "futures 0.1.29", - "mio", - "num_cpus", - "tokio-current-thread", - "tokio-executor", - "tokio-io", - "tokio-reactor", - "tokio-threadpool", - "tokio-timer", -] - -[[package]] -name = "tokio-buf" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fb220f46c53859a4b7ec083e41dec9778ff0b1851c0942b211edb89e0ccdc46" -dependencies = [ - "bytes", - "either", - "futures 0.1.29", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures 0.1.29", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils", - "futures 0.1.29", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes", - "futures 0.1.29", - "log", -] - -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils", - "futures 0.1.29", - "lazy_static", - "log", - "mio", - "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" +checksum = "7d9c43f1bb96970e153bcbae39a65e249ccb942bd9d36dbdf086024920417c9c" dependencies = [ + "bytes 0.5.4", "fnv", - "futures 0.1.29", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes", - "futures 0.1.29", + "futures-core", "iovec", - "mio", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -dependencies = [ - "crossbeam-deque", - "crossbeam-queue", - "crossbeam-utils", - "futures 0.1.29", "lazy_static", - "log", - "num_cpus", + "libc", + "memchr", + "mio", + "mio-uds", + "pin-project-lite", + "signal-hook-registry", "slab", - "tokio-executor", + "tokio-macros", + "winapi 0.3.8", ] [[package]] -name = "tokio-timer" -version = "0.2.13" +name = "tokio-macros" +version = "0.2.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" +checksum = "f0c3acc6aa564495a0f2e1d59fab677cd7f81a19994cfc7f3ad0e64301560389" dependencies = [ - "crossbeam-utils", - "futures 0.1.29", - "slab", - "tokio-executor", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-util" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "571da51182ec208780505a32528fc5512a8fe1443ab960b3f2f3ef093cd16930" +dependencies = [ + "bytes 0.5.4", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" +dependencies = [ + "bytes 0.5.4", + "futures-core", + "futures-sink", + "log", + "pin-project-lite", + "tokio", ] [[package]] @@ -2265,16 +2568,49 @@ dependencies = [ ] [[package]] -name = "try-lock" -version = "0.2.2" +name = "trust-dns-proto" +version = "0.18.0-alpha.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e604eb7b43c06650e854be16a2a03155743d3752dd1c943f6829e26b7a36e382" +checksum = "2a7f3a2ab8a919f5eca52a468866a67ed7d3efa265d48a652a9a3452272b413f" +dependencies = [ + "async-trait", + "enum-as-inner", + "failure", + "futures", + "idna", + "lazy_static", + "log", + "rand 0.7.3", + "smallvec", + "socket2", + "tokio", + "url", +] + +[[package]] +name = "trust-dns-resolver" +version = "0.18.0-alpha.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f90b1502b226f8b2514c6d5b37bafa8c200d7ca4102d57dc36ee0f3b7a04a2f" +dependencies = [ + "cfg-if", + "failure", + "futures", + "ipconfig", + "lazy_static", + "log", + "lru-cache", + "resolv-conf", + "smallvec", + "tokio", + "trust-dns-proto", +] [[package]] name = "typenum" -version = "1.11.2" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" +checksum = "373c8a200f9e67a0c95e62a4f52fbf80c23b4381c05a17845531982fa99e6b33" [[package]] name = "ucd-trie" @@ -2306,7 +2642,7 @@ version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5479532badd04e128284890390c1e876ef7a993d0570b3597ae43dfa1d59afa4" dependencies = [ - "smallvec 1.3.0", + "smallvec", ] [[package]] @@ -2335,38 +2671,27 @@ checksum = "60369ef7a31de49bcb3f6ca728d4ba7300d9a1658f94c727d4cab8c8d9f4aece" [[package]] name = "ureq" -version = "0.12.0" +version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f1c16042f50ea0cf94c451ea80b933875747e9e27ba238824e962e719885d958" +checksum = "cd754afd5f60388b4188210c3795392c5f2fd69a1cc947ec4505dbfee955b902" dependencies = [ "base64 0.12.0", "chunked_transfer", "lazy_static", "qstring", "rustls", - "url 2.1.1", + "url", "webpki", "webpki-roots", ] -[[package]] -name = "url" -version = "1.7.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" -dependencies = [ - "idna 0.1.5", - "matches", - "percent-encoding 1.0.1", -] - [[package]] name = "url" version = "2.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d4a8476c35c9bf0bbce5a3b23f4106f79728039b726d292bb93bc106787cb" dependencies = [ - "idna 0.2.0", + "idna", "matches", "percent-encoding 2.1.0", ] @@ -2416,17 +2741,6 @@ dependencies = [ "winapi-util", ] -[[package]] -name = "want" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6395efa4784b027708f7451087e647ec73cc74f5d9bc2e418404248d679a230" -dependencies = [ - "futures 0.1.29", - "log", - "try-lock", -] - [[package]] name = "wasi" version = "0.9.0+wasi-snapshot-preview1" @@ -2522,6 +2836,12 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a08eb844b158ea881e81b94556eede7f7e306e4c7b976aad88f49e6e36dec391" +[[package]] +name = "widestring" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "effc0e4ff8085673ea7b9b2e3c73f6bd4d118810c9009ed8f1e16bd96c331db6" + [[package]] name = "winapi" version = "0.2.8" @@ -2552,9 +2872,9 @@ checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] name = "winapi-util" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fa515c5163a99cc82bab70fd3bfdd36d827be85de63737b40fcef2ce084a436e" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ "winapi 0.3.8", ] @@ -2565,6 +2885,15 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "winreg" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" +dependencies = [ + "winapi 0.3.8", +] + [[package]] name = "ws2_32-sys" version = "0.2.1" diff --git a/meilisearch-core/src/database.rs b/meilisearch-core/src/database.rs index 87fc24c11..b2fdfce3a 100644 --- a/meilisearch-core/src/database.rs +++ b/meilisearch-core/src/database.rs @@ -756,16 +756,16 @@ mod tests { update_reader.abort(); let reader = db.main_read_txn().unwrap(); - let document: Option = index.document(&reader, None, DocumentId(25)).unwrap(); + let document: Option = index.document::<_, String>(&reader, None, DocumentId(25)).unwrap(); assert!(document.is_none()); let document: Option = index - .document(&reader, None, DocumentId(7_900_334_843_754_999_545)) + .document::<_, String>(&reader, None, DocumentId(7_900_334_843_754_999_545)) .unwrap(); assert!(document.is_some()); let document: Option = index - .document(&reader, None, DocumentId(8_367_468_610_878_465_872)) + .document::<_, String>(&reader, None, DocumentId(8_367_468_610_878_465_872)) .unwrap(); assert!(document.is_some()); } @@ -836,16 +836,16 @@ mod tests { update_reader.abort(); let reader = db.main_read_txn().unwrap(); - let document: Option = index.document(&reader, None, DocumentId(25)).unwrap(); + let document: Option = index.document::<_, String>(&reader, None, DocumentId(25)).unwrap(); assert!(document.is_none()); let document: Option = index - .document(&reader, None, DocumentId(7_900_334_843_754_999_545)) + .document::<_, String>(&reader, None, DocumentId(7_900_334_843_754_999_545)) .unwrap(); assert!(document.is_some()); let document: Option = index - .document(&reader, None, DocumentId(8_367_468_610_878_465_872)) + .document::<_, String>(&reader, None, DocumentId(8_367_468_610_878_465_872)) .unwrap(); assert!(document.is_some()); @@ -882,7 +882,7 @@ mod tests { let reader = db.main_read_txn().unwrap(); let document: Option = index - .document(&reader, None, DocumentId(7_900_334_843_754_999_545)) + .document::<_, String>(&reader, None, DocumentId(7_900_334_843_754_999_545)) .unwrap(); let new_doc1 = serde_json::json!({ @@ -893,7 +893,7 @@ mod tests { assert_eq!(document, Some(new_doc1)); let document: Option = index - .document(&reader, None, DocumentId(8_367_468_610_878_465_872)) + .document::<_, String>(&reader, None, DocumentId(8_367_468_610_878_465_872)) .unwrap(); let new_doc2 = serde_json::json!({ diff --git a/meilisearch-core/src/store/mod.rs b/meilisearch-core/src/store/mod.rs index 48bcfcef8..342f6c266 100644 --- a/meilisearch-core/src/store/mod.rs +++ b/meilisearch-core/src/store/mod.rs @@ -214,17 +214,17 @@ pub struct Index { } impl Index { - pub fn document( + pub fn document>( &self, reader: &heed::RoTxn, - attributes: Option<&HashSet<&str>>, + attributes: Option>, document_id: DocumentId, ) -> MResult> { let schema = self.main.schema(reader)?; let schema = schema.ok_or(Error::SchemaMissing)?; let attributes = match attributes { - Some(attributes) => Some(attributes.iter().filter_map(|name| schema.id(*name)).collect()), + Some(attributes) => Some(attributes.iter().filter_map(|name| schema.id(name.as_ref())).collect()), None => None, }; diff --git a/meilisearch-http/Cargo.toml b/meilisearch-http/Cargo.toml index b2bac5852..1c716e726 100644 --- a/meilisearch-http/Cargo.toml +++ b/meilisearch-http/Cargo.toml @@ -14,7 +14,7 @@ name = "meilisearch" path = "src/main.rs" [dependencies] -async-std = { version = "1.5.0", features = ["attributes"] } +# async-std = { version = "1.5.0", features = ["attributes"] } chrono = { version = "0.4.11", features = ["serde"] } crossbeam-channel = "0.4.2" env_logger = "0.7.1" @@ -38,11 +38,15 @@ sha2 = "0.8.1" siphasher = "0.3.2" structopt = "0.3.12" sysinfo = "0.12.0" -tide = "0.6.0" +# tide = "0.6.0" ureq = { version = "0.12.0", features = ["tls"], default-features = false } walkdir = "2.3.1" whoami = "0.8.1" slice-group-by = "0.2.6" +actix-rt = "1" +actix-web = "2" +actix-http = "1" +tokio = { version = "0.2.0", features = ["macros"] } [dev-dependencies] http-service = "0.4.0" diff --git a/meilisearch-http/src/data.rs b/meilisearch-http/src/data.rs index 5d05c02dd..3132a8dcc 100644 --- a/meilisearch-http/src/data.rs +++ b/meilisearch-http/src/data.rs @@ -10,7 +10,7 @@ use sha2::Digest; use sysinfo::Pid; use crate::option::Opt; -use crate::routes::index::index_update_callback; +// use crate::routes::index::index_update_callback; const LAST_UPDATE_KEY: &str = "last-update"; @@ -155,7 +155,7 @@ impl Data { let callback_context = data.clone(); db.set_update_callback(Box::new(move |index_uid, status| { - index_update_callback(&index_uid, &callback_context, status); + // index_update_callback(&index_uid, &callback_context, status); })); data diff --git a/meilisearch-http/src/error.rs b/meilisearch-http/src/error.rs index a4120b2ee..bd7260f3d 100644 --- a/meilisearch-http/src/error.rs +++ b/meilisearch-http/src/error.rs @@ -1,16 +1,14 @@ -use std::fmt::Display; - -use http::status::StatusCode; -use log::{error, warn}; +use std::fmt; use meilisearch_core::{FstError, HeedError}; -use serde::{Deserialize, Serialize}; -use tide::IntoResponse; -use tide::Response; +use serde_json::json; +use actix_http::{ResponseBuilder, Response}; +use actix_web::http::StatusCode; +use actix_web::*; +use futures::future::{ok, Ready}; -use crate::helpers::meilisearch::Error as SearchError; - -pub type SResult = Result; +// use crate::helpers::meilisearch::Error as SearchError; +#[derive(Debug)] pub enum ResponseError { Internal(String), BadRequest(String), @@ -23,169 +21,113 @@ pub enum ResponseError { BadParameter(String, String), OpenIndex(String), CreateIndex(String), + CreateTransaction, + CommitTransaction, + Schema, + InferPrimaryKey, InvalidIndexUid, Maintenance, } -impl ResponseError { - pub fn internal(message: impl Display) -> ResponseError { - ResponseError::Internal(message.to_string()) - } - - pub fn bad_request(message: impl Display) -> ResponseError { - ResponseError::BadRequest(message.to_string()) - } - - pub fn invalid_token(message: impl Display) -> ResponseError { - ResponseError::InvalidToken(message.to_string()) - } - - pub fn not_found(message: impl Display) -> ResponseError { - ResponseError::NotFound(message.to_string()) - } - - pub fn index_not_found(message: impl Display) -> ResponseError { - ResponseError::IndexNotFound(message.to_string()) - } - - pub fn document_not_found(message: impl Display) -> ResponseError { - ResponseError::DocumentNotFound(message.to_string()) - } - - pub fn missing_header(message: impl Display) -> ResponseError { - ResponseError::MissingHeader(message.to_string()) - } - - pub fn bad_parameter(name: impl Display, message: impl Display) -> ResponseError { - ResponseError::BadParameter(name.to_string(), message.to_string()) - } - - pub fn open_index(message: impl Display) -> ResponseError { - ResponseError::OpenIndex(message.to_string()) - } - - pub fn create_index(message: impl Display) -> ResponseError { - ResponseError::CreateIndex(message.to_string()) - } -} - -impl IntoResponse for ResponseError { - fn into_response(self) -> Response { +impl fmt::Display for ResponseError { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - ResponseError::Internal(err) => { - error!("internal server error: {}", err); - error("Internal server error".to_string(), - StatusCode::INTERNAL_SERVER_ERROR, - ) - } - ResponseError::FilterParsing(err) => { - warn!("error paring filter: {}", err); - error(format!("parsing error: {}", err), - StatusCode::BAD_REQUEST) - } - ResponseError::BadRequest(err) => { - warn!("bad request: {}", err); - error(err, StatusCode::BAD_REQUEST) - } - ResponseError::InvalidToken(err) => { - error(format!("Invalid API key: {}", err), StatusCode::FORBIDDEN) - } - ResponseError::NotFound(err) => error(err, StatusCode::NOT_FOUND), - ResponseError::IndexNotFound(index) => { - error(format!("Index {} not found", index), StatusCode::NOT_FOUND) - } - ResponseError::DocumentNotFound(id) => error( - format!("Document with id {} not found", id), - StatusCode::NOT_FOUND, - ), - ResponseError::MissingHeader(header) => error( - format!("Header {} is missing", header), - StatusCode::UNAUTHORIZED, - ), - ResponseError::BadParameter(param, e) => error( - format!("Url parameter {} error: {}", param, e), - StatusCode::BAD_REQUEST, - ), - ResponseError::CreateIndex(err) => error( - format!("Impossible to create index; {}", err), - StatusCode::BAD_REQUEST, - ), - ResponseError::OpenIndex(err) => error( - format!("Impossible to open index; {}", err), - StatusCode::BAD_REQUEST, - ), - ResponseError::InvalidIndexUid => error( - "Index must have a valid uid; Index uid can be of type integer or string only composed of alphanumeric characters, hyphens (-) and underscores (_).".to_string(), - StatusCode::BAD_REQUEST, - ), - ResponseError::Maintenance => error( - String::from("Server is in maintenance, please try again later"), - StatusCode::SERVICE_UNAVAILABLE, - ), + Self::Internal(err) => write!(f, "Internal server error: {}", err), + Self::BadRequest(err) => write!(f, "Bad request: {}", err), + Self::InvalidToken(err) => write!(f, "Invalid API key: {}", err), + Self::NotFound(err) => write!(f, "{} not found", err), + Self::IndexNotFound(index_uid) => write!(f, "Index {} not found", index_uid), + Self::DocumentNotFound(document_id) => write!(f, "Document with id {} not found", document_id), + Self::MissingHeader(header) => write!(f, "Header {} is missing", header), + Self::BadParameter(param, err) => write!(f, "Url parameter {} error: {}", param, err), + Self::OpenIndex(err) => write!(f, "Impossible to open index; {}", err), + Self::CreateIndex(err) => write!(f, "Impossible to create index; {}", err), + Self::CreateTransaction => write!(f, "Impossible to create transaction"), + Self::CommitTransaction => write!(f, "Impossible to commit transaction"), + Self::Schema => write!(f, "Internal schema is innaccessible"), + Self::InferPrimaryKey => write!(f, "Could not infer primary key"), + Self::InvalidIndexUid => write!(f, "Index must have a valid uid; Index uid can be of type integer or string only composed of alphanumeric characters, hyphens (-) and underscores (_)."), + Self::Maintenance => write!(f, "Server is in maintenance, please try again later"), + Self::FilterParsing(err) => write!(f, "parsing error: {}", err), } } } -#[derive(Serialize, Deserialize)] -struct ErrorMessage { - message: String, +impl error::ResponseError for ResponseError { + fn error_response(&self) -> HttpResponse { + ResponseBuilder::new(self.status_code()).json(json!({ + "message": self.to_string(), + })) + } + + fn status_code(&self) -> StatusCode { + match *self { + Self::Internal(_) => StatusCode::INTERNAL_SERVER_ERROR, + Self::BadRequest(_) => StatusCode::BAD_REQUEST, + Self::InvalidToken(_) => StatusCode::FORBIDDEN, + Self::NotFound(_) => StatusCode::NOT_FOUND, + Self::IndexNotFound(_) => StatusCode::NOT_FOUND, + Self::DocumentNotFound(_) => StatusCode::NOT_FOUND, + Self::MissingHeader(_) => StatusCode::UNAUTHORIZED, + Self::BadParameter(_, _) => StatusCode::BAD_REQUEST, + Self::OpenIndex(_) => StatusCode::BAD_REQUEST, + Self::CreateIndex(_) => StatusCode::BAD_REQUEST, + Self::CreateTransaction => StatusCode::INTERNAL_SERVER_ERROR, + Self::CommitTransaction => StatusCode::INTERNAL_SERVER_ERROR, + Self::Schema => StatusCode::INTERNAL_SERVER_ERROR, + Self::InferPrimaryKey => StatusCode::BAD_REQUEST, + Self::InvalidIndexUid => StatusCode::BAD_REQUEST, + Self::Maintenance => StatusCode::SERVICE_UNAVAILABLE, + Self::FilterParsing(_) => StatusCode::BAD_REQUEST, + } + } } -fn error(message: String, status: StatusCode) -> Response { - let message = ErrorMessage { message }; - tide::Response::new(status.as_u16()) - .body_json(&message) - .unwrap() -} +// impl Responder for ResponseError { +// type Error = Error; +// type Future = Ready>; + +// #[inline] +// fn respond_to(self, req: &HttpRequest) -> Self::Future { +// ok(self.error_response()) +// } +// } impl From for ResponseError { fn from(err: serde_json::Error) -> ResponseError { - ResponseError::internal(err) + ResponseError::Internal(err.to_string()) } } impl From for ResponseError { fn from(err: meilisearch_core::Error) -> ResponseError { - ResponseError::internal(err) + ResponseError::Internal(err.to_string()) } } impl From for ResponseError { fn from(err: HeedError) -> ResponseError { - ResponseError::internal(err) + ResponseError::Internal(err.to_string()) } } impl From for ResponseError { fn from(err: FstError) -> ResponseError { - ResponseError::internal(err) + ResponseError::Internal(err.to_string()) } } -impl From for ResponseError { - fn from(err: SearchError) -> ResponseError { - match err { - SearchError::FilterParsing(s) => ResponseError::FilterParsing(s), - _ => ResponseError::internal(err), - } - } -} +// impl From for ResponseError { +// fn from(err: SearchError) -> ResponseError { +// match err { +// SearchError::FilterParsing(s) => ResponseError::FilterParsing(s), +// _ => ResponseError::Internal(err), +// } +// } +// } impl From for ResponseError { fn from(err: meilisearch_core::settings::RankingRuleConversionError) -> ResponseError { - ResponseError::internal(err) - } -} - -pub trait IntoInternalError { - fn into_internal_error(self) -> SResult; -} - -impl IntoInternalError for Option { - fn into_internal_error(self) -> SResult { - match self { - Some(value) => Ok(value), - None => Err(ResponseError::internal("Heed cannot find requested value")), - } + ResponseError::Internal(err.to_string()) } } diff --git a/meilisearch-http/src/helpers/mod.rs b/meilisearch-http/src/helpers/mod.rs index 640453b8a..f42cb57c3 100644 --- a/meilisearch-http/src/helpers/mod.rs +++ b/meilisearch-http/src/helpers/mod.rs @@ -1,2 +1,2 @@ -pub mod meilisearch; -pub mod tide; +// pub mod meilisearch; +// pub mod tide; diff --git a/meilisearch-http/src/main.rs b/meilisearch-http/src/main.rs index 0703e65c9..7f44bf954 100644 --- a/meilisearch-http/src/main.rs +++ b/meilisearch-http/src/main.rs @@ -1,16 +1,14 @@ use std::{env, thread}; -use async_std::task; use log::info; use main_error::MainError; use structopt::StructOpt; -use tide::middleware::{Cors, RequestLogger, Origin}; -use http::header::HeaderValue; - +use actix_web::middleware::Logger; +use actix_web::{post, web, App, HttpServer, HttpResponse, Responder}; use meilisearch_http::data::Data; use meilisearch_http::option::Opt; use meilisearch_http::routes; -use meilisearch_http::routes::index::index_update_callback; +// use meilisearch_http::routes::index::index_update_callback; mod analytics; @@ -18,8 +16,11 @@ mod analytics; #[global_allocator] static ALLOC: jemallocator::Jemalloc = jemallocator::Jemalloc; -pub fn main() -> Result<(), MainError> { +#[tokio::main] +async fn main() -> Result<(), MainError> { let opt = Opt::from_args(); + let local = tokio::task::LocalSet::new(); + let _sys = actix_rt::System::run_in_tokio("server", &local); match opt.env.as_ref() { "production" => { @@ -29,8 +30,7 @@ pub fn main() -> Result<(), MainError> { .into(), ); } - env_logger::init(); - } + }, "development" => { env_logger::from_env(env_logger::Env::default().default_filter_or("info")).init(); } @@ -45,22 +45,27 @@ pub fn main() -> Result<(), MainError> { let data_cloned = data.clone(); data.db.set_update_callback(Box::new(move |name, status| { - index_update_callback(name, &data_cloned, status); + // index_update_callback(name, &data_cloned, status); })); print_launch_resume(&opt, &data); - let mut app = tide::with_state(data); + HttpServer::new(move || + App::new() + .wrap(Logger::default()) + .app_data(web::Data::new(data.clone())) + .service(routes::document::get_document) + .service(routes::document::delete_document) + .service(routes::document::get_all_documents) + .service(routes::document::add_documents) + .service(routes::document::update_documents) + .service(routes::document::delete_documents) + .service(routes::document::clear_all_documents) + ) + .bind(opt.http_addr)? + .run() + .await?; - app.middleware(Cors::new() - .allow_methods(HeaderValue::from_static("GET, POST, PUT, DELETE, OPTIONS")) - .allow_headers(HeaderValue::from_static("X-Meili-API-Key")) - .allow_origin(Origin::from("*"))); - app.middleware(RequestLogger::new()); - - routes::load_routes(&mut app); - - task::block_on(app.listen(opt.http_addr))?; Ok(()) } @@ -76,7 +81,7 @@ pub fn print_launch_resume(opt: &Opt, data: &Data) { 888 888 "Y8888 888 888 888 "Y8888P" "Y8888 "Y888888 888 "Y8888P 888 888 "#; - println!("{}", ascii_name); + info!("{}", ascii_name); info!("Database path: {:?}", opt.db_path); info!("Start server on: {:?}", opt.http_addr); diff --git a/meilisearch-http/src/routes/document.rs b/meilisearch-http/src/routes/document.rs index 4babe530f..a28f9a73c 100644 --- a/meilisearch-http/src/routes/document.rs +++ b/meilisearch-http/src/routes/document.rs @@ -1,111 +1,104 @@ -use std::collections::{BTreeSet, HashSet}; - +use std::collections::BTreeSet; use indexmap::IndexMap; -use serde::{Deserialize, Serialize}; +use serde::Deserialize; use serde_json::Value; -use tide::{Request, Response}; +use actix_web::*; -use crate::error::{ResponseError, SResult}; -use crate::helpers::tide::RequestExt; -use crate::helpers::tide::ACL::*; +use crate::error::ResponseError; use crate::Data; +use crate::routes::IndexUpdateResponse; -pub async fn get_document(ctx: Request) -> SResult { - ctx.is_allowed(Public)?; +type Document = IndexMap; - let index = ctx.index()?; +#[get("/indexes/{index_uid}/documents/{document_id}")] +pub async fn get_document( + data: web::Data, + path: web::Path<(String, String)>, +) -> Result { + let index = data.db.open_index(&path.0) + .ok_or(ResponseError::IndexNotFound(path.0.clone()))?; + let document_id = meilisearch_core::serde::compute_document_id(path.1.clone()); - let original_document_id = ctx.document_id()?; - let document_id = meilisearch_core::serde::compute_document_id(original_document_id.clone()); + let reader = data.db.main_read_txn() + .map_err(|_| ResponseError::CreateTransaction)?; - let db = &ctx.state().db; - let reader = db.main_read_txn()?; + let response = index.document::(&reader, None, document_id) + .map_err(|_| ResponseError::DocumentNotFound(path.1.clone()))? + .ok_or(ResponseError::DocumentNotFound(path.1.clone()))?; - let response = index - .document::>(&reader, None, document_id)? - .ok_or(ResponseError::document_not_found(&original_document_id))?; - - if response.is_empty() { - return Err(ResponseError::document_not_found(&original_document_id)); - } - - Ok(tide::Response::new(200).body_json(&response)?) + Ok(HttpResponse::Ok().json(response)) } -#[derive(Default, Serialize)] -#[serde(rename_all = "camelCase")] -pub struct IndexUpdateResponse { - pub update_id: u64, -} +#[delete("/indexes/{index_uid}/documents/{document_id}")] +pub async fn delete_document( + data: web::Data, + path: web::Path<(String, String)>, +) -> Result { + let index = data.db.open_index(&path.0) + .ok_or(ResponseError::IndexNotFound(path.0.clone()))?; + let document_id = meilisearch_core::serde::compute_document_id(path.1.clone()); -pub async fn delete_document(ctx: Request) -> SResult { - ctx.is_allowed(Private)?; + let mut update_writer = data.db.update_write_txn() + .map_err(|_| ResponseError::CreateTransaction)?; - let index = ctx.index()?; - let document_id = ctx.document_id()?; - let document_id = meilisearch_core::serde::compute_document_id(document_id); - let db = &ctx.state().db; - let mut update_writer = db.update_write_txn()?; let mut documents_deletion = index.documents_deletion(); documents_deletion.delete_document_by_id(document_id); - let update_id = documents_deletion.finalize(&mut update_writer)?; - update_writer.commit()?; + let update_id = documents_deletion.finalize(&mut update_writer) + .map_err(|_| ResponseError::Internal(path.1.clone()))?; - let response_body = IndexUpdateResponse { update_id }; - Ok(tide::Response::new(202).body_json(&response_body)?) + update_writer.commit() + .map_err(|_| ResponseError::CommitTransaction)?; + + Ok(HttpResponse::Accepted().json(IndexUpdateResponse::with_id(update_id))) } + #[derive(Default, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] -struct BrowseQuery { +pub struct BrowseQuery { offset: Option, limit: Option, attributes_to_retrieve: Option, } -pub async fn get_all_documents(ctx: Request) -> SResult { - ctx.is_allowed(Private)?; +#[get("/indexes/{index_uid}/documents")] +pub async fn get_all_documents( + data: web::Data, + path: web::Path, + params: web::Query, +) -> Result { - let index = ctx.index()?; - let query: BrowseQuery = ctx.query().unwrap_or_default(); + let index = data.db.open_index(path.clone()) + .ok_or(ResponseError::IndexNotFound(path.clone()))?; - let offset = query.offset.unwrap_or(0); - let limit = query.limit.unwrap_or(20); + let offset = params.offset.unwrap_or(0); + let limit = params.limit.unwrap_or(20); - let db = &ctx.state().db; - let reader = db.main_read_txn()?; + let reader = data.db.main_read_txn() + .map_err(|_| ResponseError::CreateTransaction)?; let documents_ids: Result, _> = index .documents_fields_counts - .documents_ids(&reader)? + .documents_ids(&reader) + .map_err(|_| ResponseError::Internal(path.clone()))? .skip(offset) .take(limit) .collect(); - let documents_ids = match documents_ids { - Ok(documents_ids) => documents_ids, - Err(e) => return Err(ResponseError::internal(e)), - }; + let documents_ids = documents_ids.map_err(|err| ResponseError::Internal(err.to_string()))?; + + let attributes = params.attributes_to_retrieve.clone() + .map(|a| a.split(',').map(|a| a.to_string()).collect()); let mut response_body = Vec::>::new(); - - if let Some(attributes) = query.attributes_to_retrieve { - let attributes = attributes.split(',').collect::>(); - for document_id in documents_ids { - if let Ok(Some(document)) = index.document(&reader, Some(&attributes), document_id) { - response_body.push(document); - } - } - } else { - for document_id in documents_ids { - if let Ok(Some(document)) = index.document(&reader, None, document_id) { - response_body.push(document); - } + for document_id in documents_ids { + if let Ok(Some(document)) = index.document(&reader, attributes.clone(), document_id) { + response_body.push(document); } } - Ok(tide::Response::new(200).body_json(&response_body)?) + Ok(HttpResponse::Ok().json(response_body)) } fn find_primary_key(document: &IndexMap) -> Option { @@ -119,40 +112,49 @@ fn find_primary_key(document: &IndexMap) -> Option { #[derive(Default, Deserialize)] #[serde(rename_all = "camelCase", deny_unknown_fields)] -struct UpdateDocumentsQuery { +pub struct UpdateDocumentsQuery { primary_key: Option, } -async fn update_multiple_documents(mut ctx: Request, is_partial: bool) -> SResult { - ctx.is_allowed(Private)?; +async fn update_multiple_documents( + data: web::Data, + path: web::Path, + params: web::Query, + body: web::Json>, + is_partial: bool +) -> Result { - let index = ctx.index()?; + let index = data.db.open_index(path.clone()) + .ok_or(ResponseError::IndexNotFound(path.clone()))?; - let data: Vec> = - ctx.body_json().await.map_err(ResponseError::bad_request)?; - let query: UpdateDocumentsQuery = ctx.query().unwrap_or_default(); + let reader = data.db.main_read_txn() + .map_err(|_| ResponseError::CreateTransaction)?; - let db = &ctx.state().db; - - let reader = db.main_read_txn()?; let mut schema = index .main - .schema(&reader)? - .ok_or(ResponseError::internal("schema not found"))?; + .schema(&reader) + .map_err(|_| ResponseError::Schema)? + .ok_or(ResponseError::Schema)?; if schema.primary_key().is_none() { - let id = match query.primary_key { + let id = match params.primary_key.clone() { Some(id) => id, - None => match data.first().and_then(|docs| find_primary_key(docs)) { - Some(id) => id, - None => return Err(ResponseError::bad_request("Could not infer a primary key")), - }, + None => { + body.first() + .and_then(|docs| find_primary_key(docs)) + .ok_or(ResponseError::InferPrimaryKey)? + } }; - let mut writer = db.main_write_txn()?; - schema.set_primary_key(&id).map_err(ResponseError::bad_request)?; - index.main.put_schema(&mut writer, &schema)?; - writer.commit()?; + let mut writer = data.db.main_write_txn() + .map_err(|_| ResponseError::CreateTransaction)?; + + schema.set_primary_key(&id) + .map_err(|e| ResponseError::Internal(e.to_string()))?; + index.main.put_schema(&mut writer, &schema) + .map_err(|e| ResponseError::Internal(e.to_string()))?; + writer.commit() + .map_err(|_| ResponseError::CommitTransaction)?; } let mut document_addition = if is_partial { @@ -161,63 +163,88 @@ async fn update_multiple_documents(mut ctx: Request, is_partial: bool) -> index.documents_addition() }; - for document in data { + for document in body.into_inner() { document_addition.update_document(document); } - let mut update_writer = db.update_write_txn()?; - let update_id = document_addition.finalize(&mut update_writer)?; - update_writer.commit()?; + let mut update_writer = data.db.update_write_txn() + .map_err(|_| ResponseError::CreateTransaction)?; + let update_id = document_addition.finalize(&mut update_writer) + .map_err(|e| ResponseError::Internal(e.to_string()))?; + update_writer.commit() + .map_err(|_| ResponseError::CommitTransaction)?; - let response_body = IndexUpdateResponse { update_id }; - Ok(tide::Response::new(202).body_json(&response_body)?) + Ok(HttpResponse::Accepted().json(IndexUpdateResponse::with_id(update_id))) } -pub async fn add_or_replace_multiple_documents(ctx: Request) -> SResult { - update_multiple_documents(ctx, false).await +#[post("/indexes/{index_uid}/documents")] +pub async fn add_documents( + data: web::Data, + path: web::Path, + params: web::Query, + body: web::Json> +) -> Result { + update_multiple_documents(data, path, params, body, false).await } -pub async fn add_or_update_multiple_documents(ctx: Request) -> SResult { - update_multiple_documents(ctx, true).await +#[put("/indexes/{index_uid}/documents")] +pub async fn update_documents( + data: web::Data, + path: web::Path, + params: web::Query, + body: web::Json> +) -> Result { + update_multiple_documents(data, path, params, body, true).await } -pub async fn delete_multiple_documents(mut ctx: Request) -> SResult { - ctx.is_allowed(Private)?; +#[post("/indexes/{index_uid}/documents/delete-batch")] +pub async fn delete_documents( + data: web::Data, + path: web::Path, + body: web::Json> +) -> Result { - let data: Vec = ctx.body_json().await.map_err(ResponseError::bad_request)?; - let index = ctx.index()?; + let index = data.db.open_index(path.clone()) + .ok_or(ResponseError::IndexNotFound(path.clone()))?; - let db = &ctx.state().db; - let mut writer = db.update_write_txn()?; + let mut writer = data.db.update_write_txn() + .map_err(|_| ResponseError::CreateTransaction)?; let mut documents_deletion = index.documents_deletion(); - for document_id in data { + for document_id in body.into_inner() { if let Some(document_id) = meilisearch_core::serde::value_to_string(&document_id) { documents_deletion .delete_document_by_id(meilisearch_core::serde::compute_document_id(document_id)); } } - let update_id = documents_deletion.finalize(&mut writer)?; + let update_id = documents_deletion.finalize(&mut writer) + .map_err(|e| ResponseError::Internal(e.to_string()))?; - writer.commit()?; + writer.commit() + .map_err(|_| ResponseError::CommitTransaction)?; - let response_body = IndexUpdateResponse { update_id }; - Ok(tide::Response::new(202).body_json(&response_body)?) + Ok(HttpResponse::Accepted().json(IndexUpdateResponse::with_id(update_id))) } -pub async fn clear_all_documents(ctx: Request) -> SResult { - ctx.is_allowed(Private)?; +#[delete("/indexes/{index_uid}/documents")] +pub async fn clear_all_documents( + data: web::Data, + path: web::Path, +) -> Result { - let index = ctx.index()?; + let index = data.db.open_index(path.clone()) + .ok_or(ResponseError::IndexNotFound(path.clone()))?; - let db = &ctx.state().db; - let mut writer = db.update_write_txn()?; + let mut writer = data.db.update_write_txn() + .map_err(|_| ResponseError::CreateTransaction)?; - let update_id = index.clear_all(&mut writer)?; - writer.commit()?; + let update_id = index.clear_all(&mut writer) + .map_err(|e| ResponseError::Internal(e.to_string()))?; - let response_body = IndexUpdateResponse { update_id }; - Ok(tide::Response::new(202).body_json(&response_body)?) + writer.commit() + .map_err(|_| ResponseError::CommitTransaction)?; + + Ok(HttpResponse::Accepted().json(IndexUpdateResponse::with_id(update_id))) } diff --git a/meilisearch-http/src/routes/mod.rs b/meilisearch-http/src/routes/mod.rs index 1d5942a08..65e09c490 100644 --- a/meilisearch-http/src/routes/mod.rs +++ b/meilisearch-http/src/routes/mod.rs @@ -1,130 +1,135 @@ -use crate::data::Data; -use std::future::Future; -use tide::IntoResponse; -use tide::Response; + +use serde::Serialize; pub mod document; -pub mod health; -pub mod index; -pub mod key; -pub mod search; -pub mod setting; -pub mod stats; -pub mod stop_words; -pub mod synonym; +// pub mod health; +// pub mod index; +// pub mod key; +// pub mod search; +// pub mod setting; +// pub mod stats; +// pub mod stop_words; +// pub mod synonym; -async fn into_response( - x: impl Future>, -) -> Response { - match x.await { - Ok(resp) => resp.into_response(), - Err(resp) => resp.into_response(), +#[derive(Default, Serialize)] +#[serde(rename_all = "camelCase")] +pub struct IndexUpdateResponse { + pub update_id: u64, + pub see_more: String, +} + +impl IndexUpdateResponse { + pub fn with_id(update_id: u64) -> Self { + Self { + update_id, + see_more: "https://docs.meilisearch.com/guides/advanced_guides/asynchronous_updates.html".to_string() + } } } -pub fn load_routes(app: &mut tide::Server) { - app.at("/").get(|_| async { - tide::Response::new(200) - .body_string(include_str!("../../public/interface.html").to_string()) - .set_mime(mime::TEXT_HTML_UTF_8) - }); - app.at("/bulma.min.css").get(|_| async { - tide::Response::new(200) - .body_string(include_str!("../../public/bulma.min.css").to_string()) - .set_mime(mime::TEXT_CSS_UTF_8) - }); +// pub fn load_routes(app: &mut tide::Server) { +// app.at("/").get(|_| async { +// tide::Response::new(200) +// .body_string(include_str!("../../public/interface.html").to_string()) +// .set_mime(mime::TEXT_HTML_UTF_8) +// }); +// app.at("/bulma.min.css").get(|_| async { +// tide::Response::new(200) +// .body_string(include_str!("../../public/bulma.min.css").to_string()) +// .set_mime(mime::TEXT_CSS_UTF_8) +// }); - app.at("/indexes") - .get(|ctx| into_response(index::list_indexes(ctx))) - .post(|ctx| into_response(index::create_index(ctx))); +// app.at("/indexes") +// .get(|ctx| into_response(index::list_indexes(ctx))) +// .post(|ctx| into_response(index::create_index(ctx))); - app.at("/indexes/search") - .post(|ctx| into_response(search::search_multi_index(ctx))); +// app.at("/indexes/search") +// .post(|ctx| into_response(search::search_multi_index(ctx))); - app.at("/indexes/:index") - .get(|ctx| into_response(index::get_index(ctx))) - .put(|ctx| into_response(index::update_index(ctx))) - .delete(|ctx| into_response(index::delete_index(ctx))); +// app.at("/indexes/:index") +// .get(|ctx| into_response(index::get_index(ctx))) +// .put(|ctx| into_response(index::update_index(ctx))) +// .delete(|ctx| into_response(index::delete_index(ctx))); - app.at("/indexes/:index/search") - .get(|ctx| into_response(search::search_with_url_query(ctx))); +// app.at("/indexes/:index/search") +// .get(|ctx| into_response(search::search_with_url_query(ctx))); - app.at("/indexes/:index/updates") - .get(|ctx| into_response(index::get_all_updates_status(ctx))); +// app.at("/indexes/:index/updates") +// .get(|ctx| into_response(index::get_all_updates_status(ctx))); - app.at("/indexes/:index/updates/:update_id") - .get(|ctx| into_response(index::get_update_status(ctx))); +// app.at("/indexes/:index/updates/:update_id") +// .get(|ctx| into_response(index::get_update_status(ctx))); - app.at("/indexes/:index/documents") - .get(|ctx| into_response(document::get_all_documents(ctx))) - .post(|ctx| into_response(document::add_or_replace_multiple_documents(ctx))) - .put(|ctx| into_response(document::add_or_update_multiple_documents(ctx))) - .delete(|ctx| into_response(document::clear_all_documents(ctx))); +// app.at("/indexes/:index/documents") +// .get(|ctx| into_response(document::get_all_documents(ctx))) +// .post(|ctx| into_response(document::add_or_replace_multiple_documents(ctx))) +// .put(|ctx| into_response(document::add_or_update_multiple_documents(ctx))) +// .delete(|ctx| into_response(document::clear_all_documents(ctx))); - app.at("/indexes/:index/documents/:document_id") - .get(|ctx| into_response(document::get_document(ctx))) - .delete(|ctx| into_response(document::delete_document(ctx))); +// app.at("/indexes/:index/documents/:document_id") +// .get(|ctx| into_response(document::get_document(ctx))) +// .delete(|ctx| into_response(document::delete_document(ctx))); - app.at("/indexes/:index/documents/delete-batch") - .post(|ctx| into_response(document::delete_multiple_documents(ctx))); +// app.at("/indexes/:index/documents/delete-batch") +// .post(|ctx| into_response(document::delete_multiple_documents(ctx))); - app.at("/indexes/:index/settings") - .get(|ctx| into_response(setting::get_all(ctx))) - .post(|ctx| into_response(setting::update_all(ctx))) - .delete(|ctx| into_response(setting::delete_all(ctx))); +// app.at("/indexes/:index/settings") +// .get(|ctx| into_response(setting::get_all(ctx))) +// .post(|ctx| into_response(setting::update_all(ctx))) +// .delete(|ctx| into_response(setting::delete_all(ctx))); - app.at("/indexes/:index/settings/ranking-rules") - .get(|ctx| into_response(setting::get_rules(ctx))) - .post(|ctx| into_response(setting::update_rules(ctx))) - .delete(|ctx| into_response(setting::delete_rules(ctx))); +// app.at("/indexes/:index/settings/ranking-rules") +// .get(|ctx| into_response(setting::get_rules(ctx))) +// .post(|ctx| into_response(setting::update_rules(ctx))) +// .delete(|ctx| into_response(setting::delete_rules(ctx))); - app.at("/indexes/:index/settings/distinct-attribute") - .get(|ctx| into_response(setting::get_distinct(ctx))) - .post(|ctx| into_response(setting::update_distinct(ctx))) - .delete(|ctx| into_response(setting::delete_distinct(ctx))); +// app.at("/indexes/:index/settings/distinct-attribute") +// .get(|ctx| into_response(setting::get_distinct(ctx))) +// .post(|ctx| into_response(setting::update_distinct(ctx))) +// .delete(|ctx| into_response(setting::delete_distinct(ctx))); - app.at("/indexes/:index/settings/searchable-attributes") - .get(|ctx| into_response(setting::get_searchable(ctx))) - .post(|ctx| into_response(setting::update_searchable(ctx))) - .delete(|ctx| into_response(setting::delete_searchable(ctx))); +// app.at("/indexes/:index/settings/searchable-attributes") +// .get(|ctx| into_response(setting::get_searchable(ctx))) +// .post(|ctx| into_response(setting::update_searchable(ctx))) +// .delete(|ctx| into_response(setting::delete_searchable(ctx))); - app.at("/indexes/:index/settings/displayed-attributes") - .get(|ctx| into_response(setting::displayed(ctx))) - .post(|ctx| into_response(setting::update_displayed(ctx))) - .delete(|ctx| into_response(setting::delete_displayed(ctx))); +// app.at("/indexes/:index/settings/displayed-attributes") +// .get(|ctx| into_response(setting::displayed(ctx))) +// .post(|ctx| into_response(setting::update_displayed(ctx))) +// .delete(|ctx| into_response(setting::delete_displayed(ctx))); - app.at("/indexes/:index/settings/accept-new-fields") - .get(|ctx| into_response(setting::get_accept_new_fields(ctx))) - .post(|ctx| into_response(setting::update_accept_new_fields(ctx))); +// app.at("/indexes/:index/settings/accept-new-fields") +// .get(|ctx| into_response(setting::get_accept_new_fields(ctx))) +// .post(|ctx| into_response(setting::update_accept_new_fields(ctx))); - app.at("/indexes/:index/settings/synonyms") - .get(|ctx| into_response(synonym::get(ctx))) - .post(|ctx| into_response(synonym::update(ctx))) - .delete(|ctx| into_response(synonym::delete(ctx))); +// app.at("/indexes/:index/settings/synonyms") +// .get(|ctx| into_response(synonym::get(ctx))) +// .post(|ctx| into_response(synonym::update(ctx))) +// .delete(|ctx| into_response(synonym::delete(ctx))); - app.at("/indexes/:index/settings/stop-words") - .get(|ctx| into_response(stop_words::get(ctx))) - .post(|ctx| into_response(stop_words::update(ctx))) - .delete(|ctx| into_response(stop_words::delete(ctx))); +// app.at("/indexes/:index/settings/stop-words") +// .get(|ctx| into_response(stop_words::get(ctx))) +// .post(|ctx| into_response(stop_words::update(ctx))) +// .delete(|ctx| into_response(stop_words::delete(ctx))); - app.at("/indexes/:index/stats") - .get(|ctx| into_response(stats::index_stats(ctx))); +// app.at("/indexes/:index/stats") +// .get(|ctx| into_response(stats::index_stats(ctx))); - app.at("/keys").get(|ctx| into_response(key::list(ctx))); +// app.at("/keys").get(|ctx| into_response(key::list(ctx))); - app.at("/health") - .get(|ctx| into_response(health::get_health(ctx))) - .put(|ctx| into_response(health::change_healthyness(ctx))); +// app.at("/health") +// .get(|ctx| into_response(health::get_health(ctx))) +// .put(|ctx| into_response(health::change_healthyness(ctx))); - app.at("/stats") - .get(|ctx| into_response(stats::get_stats(ctx))); +// app.at("/stats") +// .get(|ctx| into_response(stats::get_stats(ctx))); - app.at("/version") - .get(|ctx| into_response(stats::get_version(ctx))); +// app.at("/version") +// .get(|ctx| into_response(stats::get_version(ctx))); - app.at("/sys-info") - .get(|ctx| into_response(stats::get_sys_info(ctx))); +// app.at("/sys-info") +// .get(|ctx| into_response(stats::get_sys_info(ctx))); - app.at("/sys-info/pretty") - .get(|ctx| into_response(stats::get_sys_info_pretty(ctx))); -} +// app.at("/sys-info/pretty") +// .get(|ctx| into_response(stats::get_sys_info_pretty(ctx))); +// }