update tokio and disable all routes

This commit is contained in:
mpostma 2021-02-26 09:10:04 +01:00
parent 45d8f36f5e
commit 61ce749122
No known key found for this signature in database
GPG Key ID: CBC8A7C1D7A28C3A
14 changed files with 680 additions and 461 deletions

532
Cargo.lock generated
View File

@ -12,8 +12,24 @@ dependencies = [
"futures-sink", "futures-sink",
"log", "log",
"pin-project 0.4.27", "pin-project 0.4.27",
"tokio", "tokio 0.2.24",
"tokio-util", "tokio-util 0.3.1",
]
[[package]]
name = "actix-codec"
version = "0.4.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90673465c6187bd0829116b02be465dc0195a74d7719f76ffff0effef934a92e"
dependencies = [
"bitflags",
"bytes 1.0.1",
"futures-core",
"futures-sink",
"log",
"pin-project-lite 0.2.0",
"tokio 1.2.0",
"tokio-util 0.6.3",
] ]
[[package]] [[package]]
@ -22,27 +38,22 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "177837a10863f15ba8d3ae3ec12fac1099099529ed20083a27fdfe247381d0dc" checksum = "177837a10863f15ba8d3ae3ec12fac1099099529ed20083a27fdfe247381d0dc"
dependencies = [ dependencies = [
"actix-codec", "actix-codec 0.3.0",
"actix-rt", "actix-rt 1.1.1",
"actix-service", "actix-service 1.0.6",
"actix-utils", "actix-utils 2.0.0",
"derive_more", "derive_more",
"either", "either",
"futures-util", "futures-util",
"http", "http",
"log", "log",
"rustls",
"tokio-rustls",
"trust-dns-proto", "trust-dns-proto",
"trust-dns-resolver", "trust-dns-resolver",
"webpki",
] ]
[[package]] [[package]]
name = "actix-cors" name = "actix-cors"
version = "0.5.3" version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f3a3d5493dbc9b8769fe88c030d057ef8d2edc5728e5e26267780e8fc5db0be"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"derive_more", "derive_more",
@ -58,28 +69,25 @@ version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "452299e87817ae5673910e53c243484ca38be3828db819b6011736fc6982e874" checksum = "452299e87817ae5673910e53c243484ca38be3828db819b6011736fc6982e874"
dependencies = [ dependencies = [
"actix-codec", "actix-codec 0.3.0",
"actix-connect", "actix-connect",
"actix-rt", "actix-rt 1.1.1",
"actix-service", "actix-service 1.0.6",
"actix-threadpool", "actix-threadpool",
"actix-tls", "actix-utils 2.0.0",
"actix-utils",
"base64 0.13.0", "base64 0.13.0",
"bitflags", "bitflags",
"brotli2",
"bytes 0.5.6", "bytes 0.5.6",
"cookie", "cookie",
"copyless", "copyless",
"derive_more", "derive_more",
"either", "either",
"encoding_rs", "encoding_rs",
"flate2",
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"fxhash", "fxhash",
"h2", "h2 0.2.7",
"http", "http",
"httparse", "httparse",
"indexmap", "indexmap",
@ -100,6 +108,52 @@ dependencies = [
"time 0.2.23", "time 0.2.23",
] ]
[[package]]
name = "actix-http"
version = "3.0.0-beta.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a12706e793a92377f85cec219514b72625b3b89f9b4912d8bfb53ab6a615bf0"
dependencies = [
"actix-codec 0.4.0-beta.1",
"actix-rt 2.1.0",
"actix-service 2.0.0-beta.4",
"actix-tls",
"actix-utils 3.0.0-beta.2",
"ahash 0.7.0",
"base64 0.13.0",
"bitflags",
"brotli2",
"bytes 1.0.1",
"bytestring",
"cookie",
"derive_more",
"encoding_rs",
"flate2",
"futures-channel",
"futures-core",
"futures-util",
"h2 0.3.0",
"http",
"httparse",
"indexmap",
"itoa",
"language-tags",
"lazy_static",
"log",
"mime",
"percent-encoding",
"pin-project 1.0.2",
"rand 0.8.3",
"regex",
"serde",
"serde_json",
"serde_urlencoded",
"sha-1 0.9.2",
"slab",
"smallvec",
"time 0.2.23",
]
[[package]] [[package]]
name = "actix-macros" name = "actix-macros"
version = "0.1.3" version = "0.1.3"
@ -111,10 +165,20 @@ dependencies = [
] ]
[[package]] [[package]]
name = "actix-router" name = "actix-macros"
version = "0.2.5" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd1f7dbda1645bf7da33554db60891755f6c01c1b2169e2f4c492098d30c235" checksum = "dbcb2b608f0accc2f5bcf3dd872194ce13d94ee45b571487035864cf966b04ef"
dependencies = [
"quote",
"syn",
]
[[package]]
name = "actix-router"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2ad299af73649e1fc893e333ccf86f377751eb95ff875d095131574c6f43452c"
dependencies = [ dependencies = [
"bytestring", "bytestring",
"http", "http",
@ -129,33 +193,42 @@ version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227" checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227"
dependencies = [ dependencies = [
"actix-macros", "actix-macros 0.1.3",
"actix-threadpool", "actix-threadpool",
"copyless", "copyless",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"smallvec", "smallvec",
"tokio", "tokio 0.2.24",
]
[[package]]
name = "actix-rt"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b4e57bc1a3915e71526d128baf4323700bd1580bc676239e2298a4c5b001f18"
dependencies = [
"actix-macros 0.2.0",
"futures-core",
"tokio 1.2.0",
] ]
[[package]] [[package]]
name = "actix-server" name = "actix-server"
version = "1.0.4" version = "2.0.0-beta.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45407e6e672ca24784baa667c5d32ef109ccdd8d5e0b5ebb9ef8a67f4dfb708e" checksum = "a99198727204a48f82559c18e4b0ba3197b97d5f4576a32bdbef371f3b4599c1"
dependencies = [ dependencies = [
"actix-codec", "actix-codec 0.4.0-beta.1",
"actix-rt", "actix-rt 2.1.0",
"actix-service", "actix-service 2.0.0-beta.4",
"actix-utils", "actix-utils 3.0.0-beta.2",
"futures-channel", "futures-core",
"futures-util",
"log", "log",
"mio", "mio 0.7.9",
"mio-uds",
"num_cpus", "num_cpus",
"slab", "slab",
"socket2", "tokio 1.2.0",
] ]
[[package]] [[package]]
@ -169,17 +242,13 @@ dependencies = [
] ]
[[package]] [[package]]
name = "actix-testing" name = "actix-service"
version = "1.0.1" version = "2.0.0-beta.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47239ca38799ab74ee6a8a94d1ce857014b2ac36f242f70f3f75a66f691e791c" checksum = "ca9756f4d32984ac454ae3155a276f6be69b424197bd3f0ca3c87cde72f41d63"
dependencies = [ dependencies = [
"actix-macros", "futures-core",
"actix-rt", "pin-project-lite 0.2.0",
"actix-server",
"actix-service",
"log",
"socket2",
] ]
[[package]] [[package]]
@ -199,18 +268,21 @@ dependencies = [
[[package]] [[package]]
name = "actix-tls" name = "actix-tls"
version = "2.0.0" version = "3.0.0-beta.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24789b7d7361cf5503a504ebe1c10806896f61e96eca9a7350e23001aca715fb" checksum = "d2b1455e3f7a26d40cfc1080b571f41e8165e5a88e937ed579f7a4b3d55b0370"
dependencies = [ dependencies = [
"actix-codec", "actix-codec 0.4.0-beta.1",
"actix-service", "actix-rt 2.1.0",
"actix-utils", "actix-service 2.0.0-beta.4",
"futures-util", "actix-utils 3.0.0-beta.2",
"rustls", "derive_more",
"tokio-rustls", "futures-core",
"webpki", "http",
"webpki-roots", "log",
"tokio-rustls 0.22.0",
"tokio-util 0.6.3",
"webpki-roots 0.21.0",
] ]
[[package]] [[package]]
@ -219,9 +291,9 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e9022dec56632d1d7979e59af14f0597a28a830a9c1c7fec8b2327eb9f16b5a" checksum = "2e9022dec56632d1d7979e59af14f0597a28a830a9c1c7fec8b2327eb9f16b5a"
dependencies = [ dependencies = [
"actix-codec", "actix-codec 0.3.0",
"actix-rt", "actix-rt 1.1.1",
"actix-service", "actix-service 1.0.6",
"bitflags", "bitflags",
"bytes 0.5.6", "bytes 0.5.6",
"either", "either",
@ -234,50 +306,63 @@ dependencies = [
] ]
[[package]] [[package]]
name = "actix-web" name = "actix-utils"
version = "3.3.2" version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e641d4a172e7faa0862241a20ff4f1f5ab0ab7c279f00c2d4587b77483477b86" checksum = "458795e09a29bc5557604f9ff6f32236fd0ee457d631672e4ec8f6a0103bb292"
dependencies = [ dependencies = [
"actix-codec", "actix-codec 0.4.0-beta.1",
"actix-http", "actix-rt 2.1.0",
"actix-macros", "actix-service 2.0.0-beta.4",
"futures-core",
"futures-sink",
"log",
"pin-project-lite 0.2.0",
]
[[package]]
name = "actix-web"
version = "4.0.0-beta.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc9683dc8c3037ea524e0fec6032d34e1cb1ee72c4eb8689f428a60c2a544ea3"
dependencies = [
"actix-codec 0.4.0-beta.1",
"actix-http 3.0.0-beta.3",
"actix-macros 0.2.0",
"actix-router", "actix-router",
"actix-rt", "actix-rt 2.1.0",
"actix-server", "actix-server",
"actix-service", "actix-service 2.0.0-beta.4",
"actix-testing",
"actix-threadpool",
"actix-tls", "actix-tls",
"actix-utils", "actix-utils 3.0.0-beta.2",
"actix-web-codegen", "actix-web-codegen",
"ahash 0.7.0",
"awc", "awc",
"bytes 0.5.6", "bytes 1.0.1",
"derive_more", "derive_more",
"either",
"encoding_rs", "encoding_rs",
"futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"fxhash",
"log", "log",
"mime", "mime",
"pin-project 1.0.2", "pin-project 1.0.2",
"regex", "regex",
"rustls", "rustls 0.19.0",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"smallvec",
"socket2", "socket2",
"time 0.2.23", "time 0.2.23",
"tinyvec",
"url", "url",
] ]
[[package]] [[package]]
name = "actix-web-codegen" name = "actix-web-codegen"
version = "0.4.0" version = "0.5.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad26f77093333e0e7c6ffe54ebe3582d908a104e448723eec6d43d08b07143fb" checksum = "8313dc4cbcae1785a7f14c3dfb7dfeb25fe96a03b20e5c38fe026786def5aa70"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -305,6 +390,17 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217" checksum = "e8fd72866655d1904d6b0997d0b07ba561047d070fbe29de039031c641b61217"
[[package]]
name = "ahash"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efa60d2eadd8b12a996add391db32bd1153eac697ba4869660c0016353611426"
dependencies = [
"getrandom 0.2.2",
"once_cell",
"version_check",
]
[[package]] [[package]]
name = "aho-corasick" name = "aho-corasick"
version = "0.7.15" version = "0.7.15"
@ -348,7 +444,7 @@ dependencies = [
"futures-core", "futures-core",
"memchr", "memchr",
"pin-project-lite 0.1.11", "pin-project-lite 0.1.11",
"tokio", "tokio 0.2.24",
] ]
[[package]] [[package]]
@ -381,24 +477,24 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
[[package]] [[package]]
name = "awc" name = "awc"
version = "2.0.3" version = "3.0.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b381e490e7b0cfc37ebc54079b0413d8093ef43d14a4e4747083f7fa47a9e691" checksum = "da7225ad81fbad09ef56ccc61e0688abe8494a68722c5d0df5e2fc8b724a200b"
dependencies = [ dependencies = [
"actix-codec", "actix-codec 0.4.0-beta.1",
"actix-http", "actix-http 3.0.0-beta.3",
"actix-rt", "actix-rt 2.1.0",
"actix-service", "actix-service 2.0.0-beta.4",
"base64 0.13.0", "base64 0.13.0",
"bytes 0.5.6", "bytes 1.0.1",
"cfg-if 1.0.0", "cfg-if 1.0.0",
"derive_more", "derive_more",
"futures-core", "futures-core",
"log", "log",
"mime", "mime",
"percent-encoding", "percent-encoding",
"rand 0.7.3", "rand 0.8.3",
"rustls", "rustls 0.19.0",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
@ -563,12 +659,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e0dcbc35f504eb6fc275a6d20e4ebcda18cf50d40ba6fabff8c711fa16cb3b16" checksum = "e0dcbc35f504eb6fc275a6d20e4ebcda18cf50d40ba6fabff8c711fa16cb3b16"
[[package]] [[package]]
name = "bytestring" name = "bytes"
version = "0.1.5" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7c05fa5172da78a62d9949d662d2ac89d4cc7355d7b49adee5163f1fb3f363" checksum = "b700ce4376041dcd0a327fd0097c41095743c4c8af8887265942faf1100bd040"
[[package]]
name = "bytestring"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d"
dependencies = [ dependencies = [
"bytes 0.5.6", "bytes 1.0.1",
] ]
[[package]] [[package]]
@ -1171,8 +1273,28 @@ dependencies = [
"http", "http",
"indexmap", "indexmap",
"slab", "slab",
"tokio", "tokio 0.2.24",
"tokio-util", "tokio-util 0.3.1",
"tracing",
"tracing-futures",
]
[[package]]
name = "h2"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5"
dependencies = [
"bytes 1.0.1",
"fnv",
"futures-core",
"futures-sink",
"futures-util",
"http",
"indexmap",
"slab",
"tokio 1.2.0",
"tokio-util 0.6.3",
"tracing", "tracing",
"tracing-futures", "tracing-futures",
] ]
@ -1183,7 +1305,7 @@ version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf" checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf"
dependencies = [ dependencies = [
"ahash", "ahash 0.3.8",
"autocfg", "autocfg",
] ]
@ -1262,11 +1384,11 @@ dependencies = [
[[package]] [[package]]
name = "http" name = "http"
version = "0.2.2" version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "84129d298a6d57d246960ff8eb831ca4af3f96d29e2e28848dae275408658e26" checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747"
dependencies = [ dependencies = [
"bytes 0.5.6", "bytes 1.0.1",
"fnv", "fnv",
"itoa", "itoa",
] ]
@ -1324,7 +1446,7 @@ dependencies = [
"futures-channel", "futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2", "h2 0.2.7",
"http", "http",
"http-body", "http-body",
"httparse", "httparse",
@ -1332,7 +1454,7 @@ dependencies = [
"itoa", "itoa",
"pin-project 1.0.2", "pin-project 1.0.2",
"socket2", "socket2",
"tokio", "tokio 0.2.24",
"tower-service", "tower-service",
"tracing", "tracing",
"want", "want",
@ -1348,9 +1470,9 @@ dependencies = [
"futures-util", "futures-util",
"hyper", "hyper",
"log", "log",
"rustls", "rustls 0.18.1",
"tokio", "tokio 0.2.24",
"tokio-rustls", "tokio-rustls 0.14.1",
"webpki", "webpki",
] ]
@ -1537,9 +1659,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.81" version = "0.2.86"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb" checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
[[package]] [[package]]
name = "linked-hash-map" name = "linked-hash-map"
@ -1610,24 +1732,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08" checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
[[package]] [[package]]
name = "meilisearch-error" name = "meilisearch"
version = "0.19.0"
dependencies = [
"actix-http",
]
[[package]]
name = "meilisearch-http"
version = "0.17.0" version = "0.17.0"
dependencies = [ dependencies = [
"actix-cors", "actix-cors",
"actix-http", "actix-service 1.0.6",
"actix-rt",
"actix-service",
"actix-web", "actix-web",
"anyhow", "anyhow",
"assert-json-diff", "assert-json-diff",
"async-compression", "async-compression",
"async-trait",
"byte-unit", "byte-unit",
"bytes 0.6.0", "bytes 0.6.0",
"chrono", "chrono",
@ -1656,7 +1770,7 @@ dependencies = [
"rand 0.7.3", "rand 0.7.3",
"rayon", "rayon",
"regex", "regex",
"rustls", "rustls 0.19.0",
"sentry", "sentry",
"serde", "serde",
"serde_json", "serde_json",
@ -1668,11 +1782,20 @@ dependencies = [
"tar", "tar",
"tempdir", "tempdir",
"tempfile", "tempfile",
"tokio", "thiserror",
"tokio 0.2.24",
"tokio 1.2.0",
"uuid", "uuid",
"vergen", "vergen",
] ]
[[package]]
name = "meilisearch-error"
version = "0.19.0"
dependencies = [
"actix-http 2.2.0",
]
[[package]] [[package]]
name = "meilisearch-tokenizer" name = "meilisearch-tokenizer"
version = "0.1.1" version = "0.1.1"
@ -1799,14 +1922,15 @@ dependencies = [
] ]
[[package]] [[package]]
name = "mio-named-pipes" name = "mio"
version = "0.1.7" version = "0.7.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656" checksum = "a5dede4e2065b3842b8b0af444119f3aa331cc7cc2dd20388bfb0f5d5a38823a"
dependencies = [ dependencies = [
"libc",
"log", "log",
"mio",
"miow 0.3.6", "miow 0.3.6",
"ntapi",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -1818,7 +1942,7 @@ checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0"
dependencies = [ dependencies = [
"iovec", "iovec",
"libc", "libc",
"mio", "mio 0.6.23",
] ]
[[package]] [[package]]
@ -1866,6 +1990,15 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "ntapi"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44"
dependencies = [
"winapi 0.3.9",
]
[[package]] [[package]]
name = "num-integer" name = "num-integer"
version = "0.1.44" version = "0.1.44"
@ -2215,12 +2348,24 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
dependencies = [ dependencies = [
"getrandom 0.1.15", "getrandom 0.1.15",
"libc", "libc",
"rand_chacha", "rand_chacha 0.2.2",
"rand_core 0.5.1", "rand_core 0.5.1",
"rand_hc", "rand_hc 0.2.0",
"rand_pcg", "rand_pcg",
] ]
[[package]]
name = "rand"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ef9e7e66b4468674bfcb0c81af8b7fa0bb154fa9f28eb840da5c447baeb8d7e"
dependencies = [
"libc",
"rand_chacha 0.3.0",
"rand_core 0.6.2",
"rand_hc 0.3.0",
]
[[package]] [[package]]
name = "rand_chacha" name = "rand_chacha"
version = "0.2.2" version = "0.2.2"
@ -2231,6 +2376,16 @@ dependencies = [
"rand_core 0.5.1", "rand_core 0.5.1",
] ]
[[package]]
name = "rand_chacha"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12735cf05c9e10bf21534da50a147b924d555dc7a547c42e6bb2d5b6017ae0d"
dependencies = [
"ppv-lite86",
"rand_core 0.6.2",
]
[[package]] [[package]]
name = "rand_core" name = "rand_core"
version = "0.3.1" version = "0.3.1"
@ -2255,6 +2410,15 @@ dependencies = [
"getrandom 0.1.15", "getrandom 0.1.15",
] ]
[[package]]
name = "rand_core"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34cf66eb183df1c5876e2dcf6b13d57340741e8dc255b48e40a26de954d06ae7"
dependencies = [
"getrandom 0.2.2",
]
[[package]] [[package]]
name = "rand_hc" name = "rand_hc"
version = "0.2.0" version = "0.2.0"
@ -2264,6 +2428,15 @@ dependencies = [
"rand_core 0.5.1", "rand_core 0.5.1",
] ]
[[package]]
name = "rand_hc"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3190ef7066a446f2e7f42e239d161e905420ccab01eb967c9eb27d21b2322a73"
dependencies = [
"rand_core 0.6.2",
]
[[package]] [[package]]
name = "rand_pcg" name = "rand_pcg"
version = "0.2.1" version = "0.2.1"
@ -2381,17 +2554,17 @@ dependencies = [
"mime_guess", "mime_guess",
"percent-encoding", "percent-encoding",
"pin-project-lite 0.2.0", "pin-project-lite 0.2.0",
"rustls", "rustls 0.18.1",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"tokio", "tokio 0.2.24",
"tokio-rustls", "tokio-rustls 0.14.1",
"url", "url",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
"webpki-roots", "webpki-roots 0.20.0",
"winreg 0.7.0", "winreg 0.7.0",
] ]
@ -2457,6 +2630,19 @@ dependencies = [
"webpki", "webpki",
] ]
[[package]]
name = "rustls"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "064fd21ff87c6e87ed4506e68beb42459caa4a0e2eb144932e6776768556980b"
dependencies = [
"base64 0.13.0",
"log",
"ring",
"sct",
"webpki",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
version = "1.0.5" version = "1.0.5"
@ -2680,9 +2866,9 @@ dependencies = [
[[package]] [[package]]
name = "smallvec" name = "smallvec"
version = "1.5.1" version = "1.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75" checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
[[package]] [[package]]
name = "snap" name = "snap"
@ -2883,18 +3069,18 @@ dependencies = [
[[package]] [[package]]
name = "thiserror" name = "thiserror"
version = "1.0.22" version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e" checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
dependencies = [ dependencies = [
"thiserror-impl", "thiserror-impl",
] ]
[[package]] [[package]]
name = "thiserror-impl" name = "thiserror-impl"
version = "1.0.22" version = "1.0.24"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56" checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -2996,14 +3182,33 @@ dependencies = [
"lazy_static", "lazy_static",
"libc", "libc",
"memchr", "memchr",
"mio", "mio 0.6.23",
"mio-named-pipes",
"mio-uds", "mio-uds",
"num_cpus", "num_cpus",
"pin-project-lite 0.1.11", "pin-project-lite 0.1.11",
"signal-hook-registry", "signal-hook-registry",
"slab", "slab",
"tokio-macros", "tokio-macros 0.2.6",
"winapi 0.3.9",
]
[[package]]
name = "tokio"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8190d04c665ea9e6b6a0dc45523ade572c088d2e6566244c1122671dbf4ae3a"
dependencies = [
"autocfg",
"bytes 1.0.1",
"libc",
"memchr",
"mio 0.7.9",
"num_cpus",
"once_cell",
"parking_lot",
"pin-project-lite 0.2.0",
"signal-hook-registry",
"tokio-macros 1.1.0",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -3018,6 +3223,17 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "tokio-macros"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "caf7b11a536f46a809a8a9f0bb4237020f70ecbf115b842360afb127ea2fda57"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]] [[package]]
name = "tokio-rustls" name = "tokio-rustls"
version = "0.14.1" version = "0.14.1"
@ -3025,8 +3241,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a" checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a"
dependencies = [ dependencies = [
"futures-core", "futures-core",
"rustls", "rustls 0.18.1",
"tokio", "tokio 0.2.24",
"webpki",
]
[[package]]
name = "tokio-rustls"
version = "0.22.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6"
dependencies = [
"rustls 0.19.0",
"tokio 1.2.0",
"webpki", "webpki",
] ]
@ -3041,7 +3268,21 @@ dependencies = [
"futures-sink", "futures-sink",
"log", "log",
"pin-project-lite 0.1.11", "pin-project-lite 0.1.11",
"tokio", "tokio 0.2.24",
]
[[package]]
name = "tokio-util"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ebb7cb2f00c5ae8df755b252306272cd1790d39728363936e01827e11f0b017b"
dependencies = [
"bytes 1.0.1",
"futures-core",
"futures-sink",
"log",
"pin-project-lite 0.2.0",
"tokio 1.2.0",
] ]
[[package]] [[package]]
@ -3097,7 +3338,7 @@ dependencies = [
"rand 0.7.3", "rand 0.7.3",
"smallvec", "smallvec",
"thiserror", "thiserror",
"tokio", "tokio 0.2.24",
"url", "url",
] ]
@ -3117,7 +3358,7 @@ dependencies = [
"resolv-conf", "resolv-conf",
"smallvec", "smallvec",
"thiserror", "thiserror",
"tokio", "tokio 0.2.24",
"trust-dns-proto", "trust-dns-proto",
] ]
@ -3369,6 +3610,15 @@ dependencies = [
"webpki", "webpki",
] ]
[[package]]
name = "webpki-roots"
version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "82015b7e0b8bad8185994674a13a93306bea76cf5a16c5a181382fd3a5ec2376"
dependencies = [
"webpki",
]
[[package]] [[package]]
name = "whatlang" name = "whatlang"
version = "0.9.0" version = "0.9.0"

View File

@ -3,7 +3,7 @@ authors = ["Quentin de Quelen <quentin@dequelen.me>", "Clément Renault <clement
description = "MeiliSearch HTTP server" description = "MeiliSearch HTTP server"
edition = "2018" edition = "2018"
license = "MIT" license = "MIT"
name = "meilisearch-http" name = "meilisearch"
version = "0.17.0" version = "0.17.0"
[[bin]] [[bin]]
name = "meilisearch" name = "meilisearch"
@ -13,11 +13,11 @@ path = "src/main.rs"
vergen = "3.1.0" vergen = "3.1.0"
[dependencies] [dependencies]
actix-cors = "0.5.3" actix-cors = { path = "../actix-extras/actix-cors" }
actix-http = "2" #actix-http = "2"
actix-rt = "1"
actix-service = "1.0.6" actix-service = "1.0.6"
actix-web = { version = "3.3.2", features = ["rustls"] } actix-web = { version = "4.0.0-beta.3", features = ["rustls"] }
#actix-web = { version = "3", features = ["rustls"] }
anyhow = "1.0.36" anyhow = "1.0.36"
async-compression = { version = "0.3.6", features = ["gzip", "tokio-02"] } async-compression = { version = "0.3.6", features = ["gzip", "tokio-02"] }
byte-unit = { version = "4.0.9", default-features = false, features = ["std"] } byte-unit = { version = "4.0.9", default-features = false, features = ["std"] }
@ -44,7 +44,7 @@ once_cell = "1.5.2"
rand = "0.7.3" rand = "0.7.3"
rayon = "1.5.0" rayon = "1.5.0"
regex = "1.4.2" regex = "1.4.2"
rustls = "0.18" rustls = "0.19"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0.59", features = ["preserve_order"] } serde_json = { version = "1.0.59", features = ["preserve_order"] }
sha2 = "0.9.1" sha2 = "0.9.1"
@ -53,11 +53,13 @@ slice-group-by = "0.2.6"
structopt = "0.3.20" structopt = "0.3.20"
tar = "0.4.29" tar = "0.4.29"
tempfile = "3.1.0" tempfile = "3.1.0"
tokio = { version = "0.2", features = ["full"] } tokio = { version = "1", features = ["full"] }
dashmap = "4.0.2" dashmap = "4.0.2"
uuid = "0.8.2" uuid = "0.8.2"
itertools = "0.10.0" itertools = "0.10.0"
either = "1.6.1" either = "1.6.1"
async-trait = "0.1.42"
thiserror = "1.0.24"
[dependencies.sentry] [dependencies.sentry]
default-features = false default-features = false

View File

@ -9,7 +9,8 @@ use std::sync::Arc;
use sha2::Digest; use sha2::Digest;
use crate::index_controller::{IndexController, LocalIndexController, IndexMetadata, Settings, IndexSettings}; use crate::index_controller::{IndexController, IndexMetadata, Settings, IndexSettings};
use crate::index_controller::actor_index_controller::ActorIndexController;
use crate::option::Opt; use crate::option::Opt;
#[derive(Clone)] #[derive(Clone)]
@ -27,7 +28,7 @@ impl Deref for Data {
#[derive(Clone)] #[derive(Clone)]
pub struct DataInner { pub struct DataInner {
pub index_controller: Arc<LocalIndexController>, pub index_controller: Arc<dyn IndexController + Send + Sync>,
pub api_keys: ApiKeys, pub api_keys: ApiKeys,
options: Opt, options: Opt,
} }
@ -59,14 +60,9 @@ impl ApiKeys {
impl Data { impl Data {
pub fn new(options: Opt) -> anyhow::Result<Data> { pub fn new(options: Opt) -> anyhow::Result<Data> {
let path = options.db_path.clone(); let path = options.db_path.clone();
let indexer_opts = options.indexer_options.clone(); //let indexer_opts = options.indexer_options.clone();
create_dir_all(&path)?; create_dir_all(&path)?;
let index_controller = LocalIndexController::new( let index_controller = ActorIndexController::new();
&path,
indexer_opts,
options.max_mdb_size.get_bytes(),
options.max_udb_size.get_bytes(),
)?;
let index_controller = Arc::new(index_controller); let index_controller = Arc::new(index_controller);
let mut api_keys = ApiKeys { let mut api_keys = ApiKeys {
@ -85,7 +81,7 @@ impl Data {
pub fn settings<S: AsRef<str>>(&self, index_uid: S) -> anyhow::Result<Settings> { pub fn settings<S: AsRef<str>>(&self, index_uid: S) -> anyhow::Result<Settings> {
let index = self.index_controller let index = self.index_controller
.index(&index_uid)? .index(index_uid.as_ref().to_string())?
.ok_or_else(|| anyhow::anyhow!("Index {} does not exist.", index_uid.as_ref()))?; .ok_or_else(|| anyhow::anyhow!("Index {} does not exist.", index_uid.as_ref()))?;
let txn = index.read_txn()?; let txn = index.read_txn()?;
@ -119,19 +115,20 @@ impl Data {
} }
pub fn index(&self, name: impl AsRef<str>) -> anyhow::Result<Option<IndexMetadata>> { pub fn index(&self, name: impl AsRef<str>) -> anyhow::Result<Option<IndexMetadata>> {
Ok(self todo!()
.list_indexes()? //Ok(self
.into_iter() //.list_indexes()?
.find(|i| i.uid == name.as_ref())) //.into_iter()
//.find(|i| i.uid == name.as_ref()))
} }
pub fn create_index(&self, name: impl AsRef<str>, primary_key: Option<impl AsRef<str>>) -> anyhow::Result<IndexMetadata> { pub async fn create_index(&self, name: impl AsRef<str>, primary_key: Option<impl AsRef<str>>) -> anyhow::Result<IndexMetadata> {
let settings = IndexSettings { let settings = IndexSettings {
name: Some(name.as_ref().to_string()), name: Some(name.as_ref().to_string()),
primary_key: primary_key.map(|s| s.as_ref().to_string()), primary_key: primary_key.map(|s| s.as_ref().to_string()),
}; };
let meta = self.index_controller.create_index(settings)?; let meta = self.index_controller.create_index(settings).await?;
Ok(meta) Ok(meta)
} }

View File

@ -2,7 +2,7 @@ use std::collections::{HashSet, BTreeMap};
use std::mem; use std::mem;
use std::time::Instant; use std::time::Instant;
use anyhow::{bail, Context}; use anyhow::bail;
use either::Either; use either::Either;
use heed::RoTxn; use heed::RoTxn;
use meilisearch_tokenizer::{Analyzer, AnalyzerConfig}; use meilisearch_tokenizer::{Analyzer, AnalyzerConfig};
@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize};
use serde_json::{Map, Value}; use serde_json::{Map, Value};
use super::Data; use super::Data;
use crate::index_controller::IndexController;
pub const DEFAULT_SEARCH_LIMIT: usize = 20; pub const DEFAULT_SEARCH_LIMIT: usize = 20;
@ -202,107 +201,110 @@ impl<'a, A: AsRef<[u8]>> Highlighter<'a, A> {
impl Data { impl Data {
pub fn search<S: AsRef<str>>( pub fn search<S: AsRef<str>>(
&self, &self,
index: S, _index: S,
search_query: SearchQuery, _search_query: SearchQuery,
) -> anyhow::Result<SearchResult> { ) -> anyhow::Result<SearchResult> {
match self.index_controller.index(&index)? { todo!()
Some(index) => Ok(search_query.perform(index)?), //match self.index_controller.index(&index)? {
None => bail!("index {:?} doesn't exists", index.as_ref()), //Some(index) => Ok(search_query.perform(index)?),
} //None => bail!("index {:?} doesn't exists", index.as_ref()),
//}
} }
pub async fn retrieve_documents<S>( pub async fn retrieve_documents<S>(
&self, &self,
index: impl AsRef<str> + Send + Sync + 'static, _index: String,
offset: usize, _offset: usize,
limit: usize, _limit: usize,
attributes_to_retrieve: Option<Vec<S>>, _attributes_to_retrieve: Option<Vec<S>>,
) -> anyhow::Result<Vec<Map<String, Value>>> ) -> anyhow::Result<Vec<Map<String, Value>>>
where where
S: AsRef<str> + Send + Sync + 'static, S: AsRef<str> + Send + Sync + 'static,
{ {
let index_controller = self.index_controller.clone(); todo!()
let documents: anyhow::Result<_> = tokio::task::spawn_blocking(move || { //let index_controller = self.index_controller.clone();
let index = index_controller //let documents: anyhow::Result<_> = tokio::task::spawn_blocking(move || {
.index(&index)? //let index = index_controller
.with_context(|| format!("Index {:?} doesn't exist", index.as_ref()))?; //.index(index.clone())?
//.with_context(|| format!("Index {:?} doesn't exist", index))?;
let txn = index.read_txn()?; //let txn = index.read_txn()?;
let fields_ids_map = index.fields_ids_map(&txn)?; //let fields_ids_map = index.fields_ids_map(&txn)?;
let attributes_to_retrieve_ids = match attributes_to_retrieve { //let attributes_to_retrieve_ids = match attributes_to_retrieve {
Some(attrs) => attrs //Some(attrs) => attrs
.iter() //.iter()
.filter_map(|f| fields_ids_map.id(f.as_ref())) //.filter_map(|f| fields_ids_map.id(f.as_ref()))
.collect::<Vec<_>>(), //.collect::<Vec<_>>(),
None => fields_ids_map.iter().map(|(id, _)| id).collect(), //None => fields_ids_map.iter().map(|(id, _)| id).collect(),
}; //};
let iter = index.documents.range(&txn, &(..))?.skip(offset).take(limit); //let iter = index.documents.range(&txn, &(..))?.skip(offset).take(limit);
let mut documents = Vec::new(); //let mut documents = Vec::new();
for entry in iter { //for entry in iter {
let (_id, obkv) = entry?; //let (_id, obkv) = entry?;
let object = obkv_to_json(&attributes_to_retrieve_ids, &fields_ids_map, obkv)?; //let object = obkv_to_json(&attributes_to_retrieve_ids, &fields_ids_map, obkv)?;
documents.push(object); //documents.push(object);
} //}
Ok(documents) //Ok(documents)
}) //})
.await?; //.await?;
documents //documents
} }
pub async fn retrieve_document<S>( pub async fn retrieve_document<S>(
&self, &self,
index: impl AsRef<str> + Sync + Send + 'static, _index: impl AsRef<str> + Sync + Send + 'static,
document_id: impl AsRef<str> + Sync + Send + 'static, _document_id: impl AsRef<str> + Sync + Send + 'static,
attributes_to_retrieve: Option<Vec<S>>, _attributes_to_retrieve: Option<Vec<S>>,
) -> anyhow::Result<Map<String, Value>> ) -> anyhow::Result<Map<String, Value>>
where where
S: AsRef<str> + Sync + Send + 'static, S: AsRef<str> + Sync + Send + 'static,
{ {
let index_controller = self.index_controller.clone(); todo!()
let document: anyhow::Result<_> = tokio::task::spawn_blocking(move || { //let index_controller = self.index_controller.clone();
let index = index_controller //let document: anyhow::Result<_> = tokio::task::spawn_blocking(move || {
.index(&index)? //let index = index_controller
.with_context(|| format!("Index {:?} doesn't exist", index.as_ref()))?; //.index(&index)?
let txn = index.read_txn()?; //.with_context(|| format!("Index {:?} doesn't exist", index.as_ref()))?;
//let txn = index.read_txn()?;
let fields_ids_map = index.fields_ids_map(&txn)?; //let fields_ids_map = index.fields_ids_map(&txn)?;
let attributes_to_retrieve_ids = match attributes_to_retrieve { //let attributes_to_retrieve_ids = match attributes_to_retrieve {
Some(attrs) => attrs //Some(attrs) => attrs
.iter() //.iter()
.filter_map(|f| fields_ids_map.id(f.as_ref())) //.filter_map(|f| fields_ids_map.id(f.as_ref()))
.collect::<Vec<_>>(), //.collect::<Vec<_>>(),
None => fields_ids_map.iter().map(|(id, _)| id).collect(), //None => fields_ids_map.iter().map(|(id, _)| id).collect(),
}; //};
let internal_id = index //let internal_id = index
.external_documents_ids(&txn)? //.external_documents_ids(&txn)?
.get(document_id.as_ref().as_bytes()) //.get(document_id.as_ref().as_bytes())
.with_context(|| format!("Document with id {} not found", document_id.as_ref()))?; //.with_context(|| format!("Document with id {} not found", document_id.as_ref()))?;
let document = index //let document = index
.documents(&txn, std::iter::once(internal_id))? //.documents(&txn, std::iter::once(internal_id))?
.into_iter() //.into_iter()
.next() //.next()
.map(|(_, d)| d); //.map(|(_, d)| d);
match document { //match document {
Some(document) => Ok(obkv_to_json( //Some(document) => Ok(obkv_to_json(
&attributes_to_retrieve_ids, //&attributes_to_retrieve_ids,
&fields_ids_map, //&fields_ids_map,
document, //document,
)?), //)?),
None => bail!("Document with id {} not found", document_id.as_ref()), //None => bail!("Document with id {} not found", document_id.as_ref()),
} //}
}) //})
.await?; //.await?;
document //document
} }
} }

View File

@ -1,12 +1,13 @@
use std::ops::Deref; use std::ops::Deref;
use async_compression::tokio_02::write::GzipEncoder; //use async_compression::tokio_02::write::GzipEncoder;
use futures_util::stream::StreamExt; //use futures_util::stream::StreamExt;
use milli::update::{IndexDocumentsMethod, UpdateFormat}; //use milli::update::{IndexDocumentsMethod, UpdateFormat};
use tokio::io::AsyncWriteExt; //use tokio::io::AsyncWriteExt;
use actix_web::web::Payload;
use crate::index_controller::UpdateStatus; use crate::index_controller::UpdateStatus;
use crate::index_controller::{IndexController, Settings, IndexSettings, IndexMetadata}; use crate::index_controller::{Settings, IndexMetadata};
use super::Data; use super::Data;
impl Data { impl Data {
@ -15,88 +16,68 @@ impl Data {
index: impl AsRef<str> + Send + Sync + 'static, index: impl AsRef<str> + Send + Sync + 'static,
method: IndexDocumentsMethod, method: IndexDocumentsMethod,
format: UpdateFormat, format: UpdateFormat,
mut stream: impl futures::Stream<Item=Result<B, E>> + Unpin, stream: Payload,
primary_key: Option<String>, primary_key: Option<String>,
) -> anyhow::Result<UpdateStatus> ) -> anyhow::Result<UpdateStatus>
where where
B: Deref<Target = [u8]>, B: Deref<Target = [u8]>,
E: std::error::Error + Send + Sync + 'static, E: std::error::Error + Send + Sync + 'static,
{ {
let file = tokio::task::spawn_blocking(tempfile::tempfile).await?; let update_status = self.index_controller.add_documents(index.as_ref().to_string(), method, format, stream, primary_key).await?;
let file = tokio::fs::File::from_std(file?); Ok(update_status)
let mut encoder = GzipEncoder::new(file);
let mut empty_update = true;
while let Some(result) = stream.next().await {
empty_update = false;
let bytes = &*result?;
encoder.write_all(&bytes[..]).await?;
}
encoder.shutdown().await?;
let mut file = encoder.into_inner();
file.sync_all().await?;
let file = file.into_std().await;
let index_controller = self.index_controller.clone();
let update = tokio::task::spawn_blocking(move ||{
let mmap;
let bytes = if empty_update {
&[][..]
} else {
mmap = unsafe { memmap::Mmap::map(&file)? };
&mmap
};
index_controller.add_documents(index, method, format, &bytes, primary_key)
}).await??;
Ok(update.into())
} }
pub async fn update_settings( pub async fn update_settings(
&self, &self,
index: impl AsRef<str> + Send + Sync + 'static, _index: impl AsRef<str> + Send + Sync + 'static,
settings: Settings _settings: Settings
) -> anyhow::Result<UpdateStatus> { ) -> anyhow::Result<UpdateStatus> {
let index_controller = self.index_controller.clone(); todo!()
let update = tokio::task::spawn_blocking(move || index_controller.update_settings(index, settings)).await??; //let index_controller = self.index_controller.clone();
Ok(update.into()) //let update = tokio::task::spawn_blocking(move || index_controller.update_settings(index, settings)).await??;
//Ok(update.into())
} }
pub async fn clear_documents( pub async fn clear_documents(
&self, &self,
index: impl AsRef<str> + Sync + Send + 'static, _index: impl AsRef<str> + Sync + Send + 'static,
) -> anyhow::Result<UpdateStatus> { ) -> anyhow::Result<UpdateStatus> {
let index_controller = self.index_controller.clone(); todo!()
let update = tokio::task::spawn_blocking(move || index_controller.clear_documents(index)).await??; //let index_controller = self.index_controller.clone();
Ok(update.into()) //let update = tokio::task::spawn_blocking(move || index_controller.clear_documents(index)).await??;
//Ok(update.into())
} }
pub async fn delete_documents( pub async fn delete_documents(
&self, &self,
index: impl AsRef<str> + Sync + Send + 'static, _index: impl AsRef<str> + Sync + Send + 'static,
document_ids: Vec<String>, _document_ids: Vec<String>,
) -> anyhow::Result<UpdateStatus> { ) -> anyhow::Result<UpdateStatus> {
let index_controller = self.index_controller.clone(); todo!()
let update = tokio::task::spawn_blocking(move || index_controller.delete_documents(index, document_ids)).await??; //let index_controller = self.index_controller.clone();
Ok(update.into()) //let update = tokio::task::spawn_blocking(move || index_controller.delete_documents(index, document_ids)).await??;
//Ok(update.into())
} }
pub async fn delete_index( pub async fn delete_index(
&self, &self,
index: impl AsRef<str> + Send + Sync + 'static, _index: impl AsRef<str> + Send + Sync + 'static,
) -> anyhow::Result<()> { ) -> anyhow::Result<()> {
let index_controller = self.index_controller.clone(); todo!()
tokio::task::spawn_blocking(move || { index_controller.delete_index(index) }).await??; //let index_controller = self.index_controller.clone();
Ok(()) //tokio::task::spawn_blocking(move || { index_controller.delete_index(index) }).await??;
//Ok(())
} }
#[inline] #[inline]
pub fn get_update_status(&self, index: impl AsRef<str>, uid: u64) -> anyhow::Result<Option<UpdateStatus>> { pub fn get_update_status(&self, index: impl AsRef<str>, uid: u64) -> anyhow::Result<Option<UpdateStatus>> {
self.index_controller.update_status(index, uid) todo!()
//self.index_controller.update_status(index, uid)
} }
pub fn get_updates_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus>> { pub fn get_updates_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus>> {
self.index_controller.all_update_status(index) todo!()
//self.index_controller.all_update_status(index)
} }
pub fn update_index( pub fn update_index(
@ -105,11 +86,12 @@ impl Data {
primary_key: Option<impl AsRef<str>>, primary_key: Option<impl AsRef<str>>,
new_name: Option<impl AsRef<str>> new_name: Option<impl AsRef<str>>
) -> anyhow::Result<IndexMetadata> { ) -> anyhow::Result<IndexMetadata> {
let settings = IndexSettings { todo!()
name: new_name.map(|s| s.as_ref().to_string()), //let settings = IndexSettings {
primary_key: primary_key.map(|s| s.as_ref().to_string()), //name: new_name.map(|s| s.as_ref().to_string()),
}; //primary_key: primary_key.map(|s| s.as_ref().to_string()),
//};
self.index_controller.update_index(name, settings) //self.index_controller.update_index(name, settings)
} }
} }

View File

@ -1,7 +1,8 @@
use std::error; use std::error;
use std::fmt; use std::fmt;
use actix_http::ResponseBuilder; use actix_web::dev::HttpResponseBuilder;
use actix_web::http::Error as HttpError;
use actix_web as aweb; use actix_web as aweb;
use actix_web::error::{JsonPayloadError, QueryPayloadError}; use actix_web::error::{JsonPayloadError, QueryPayloadError};
use actix_web::http::StatusCode; use actix_web::http::StatusCode;
@ -66,7 +67,7 @@ impl Serialize for ResponseError {
impl aweb::error::ResponseError for ResponseError { impl aweb::error::ResponseError for ResponseError {
fn error_response(&self) -> aweb::HttpResponse { fn error_response(&self) -> aweb::HttpResponse {
ResponseBuilder::new(self.status_code()).json(&self) HttpResponseBuilder::new(self.status_code()).json(&self)
} }
fn status_code(&self) -> StatusCode { fn status_code(&self) -> StatusCode {
@ -260,8 +261,8 @@ impl From<std::io::Error> for Error {
} }
} }
impl From<actix_http::Error> for Error { impl From<HttpError> for Error {
fn from(err: actix_http::Error) -> Error { fn from(err: HttpError) -> Error {
Error::Internal(err.to_string()) Error::Internal(err.to_string())
} }
} }

View File

@ -3,27 +3,26 @@ use std::pin::Pin;
use std::rc::Rc; use std::rc::Rc;
use std::task::{Context, Poll}; use std::task::{Context, Poll};
use actix_service::{Service, Transform}; use actix_web::dev::{Transform, Service, ServiceResponse, ServiceRequest};
use actix_web::{dev::ServiceRequest, dev::ServiceResponse, web}; use actix_web::web;
use futures::future::{err, ok, Future, Ready}; use futures::future::{err, ok, Future, Ready};
use crate::error::{Error, ResponseError}; use crate::error::{Error, ResponseError};
use crate::Data; use crate::Data;
#[derive(Clone)] #[derive(Clone, Copy)]
pub enum Authentication { pub enum Authentication {
Public, Public,
Private, Private,
Admin, Admin,
} }
impl<S: 'static, B> Transform<S> for Authentication impl<S: 'static, B> Transform<S, ServiceRequest> for Authentication
where where
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>, S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error>,
S::Future: 'static, S::Future: 'static,
B: 'static, B: 'static,
{ {
type Request = ServiceRequest;
type Response = ServiceResponse<B>; type Response = ServiceResponse<B>;
type Error = actix_web::Error; type Error = actix_web::Error;
type InitError = (); type InitError = ();
@ -32,7 +31,7 @@ where
fn new_transform(&self, service: S) -> Self::Future { fn new_transform(&self, service: S) -> Self::Future {
ok(LoggingMiddleware { ok(LoggingMiddleware {
acl: self.clone(), acl: *self,
service: Rc::new(RefCell::new(service)), service: Rc::new(RefCell::new(service)),
}) })
} }
@ -44,23 +43,22 @@ pub struct LoggingMiddleware<S> {
} }
#[allow(clippy::type_complexity)] #[allow(clippy::type_complexity)]
impl<S, B> Service for LoggingMiddleware<S> impl<S, B> Service<ServiceRequest> for LoggingMiddleware<S>
where where
S: Service<Request = ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error> + 'static, S: Service<ServiceRequest, Response = ServiceResponse<B>, Error = actix_web::Error> + 'static,
S::Future: 'static, S::Future: 'static,
B: 'static, B: 'static,
{ {
type Request = ServiceRequest;
type Response = ServiceResponse<B>; type Response = ServiceResponse<B>;
type Error = actix_web::Error; type Error = actix_web::Error;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>; type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>>>>;
fn poll_ready(&mut self, cx: &mut Context) -> Poll<Result<(), Self::Error>> { fn poll_ready(&self, cx: &mut Context) -> Poll<Result<(), Self::Error>> {
self.service.poll_ready(cx) self.service.poll_ready(cx)
} }
fn call(&mut self, req: ServiceRequest) -> Self::Future { fn call(&self, req: ServiceRequest) -> Self::Future {
let mut svc = self.service.clone(); let svc = self.service.clone();
// This unwrap is left because this error should never appear. If that's the case, then // This unwrap is left because this error should never appear. If that's the case, then
// it means that actix-web has an issue or someone changes the type `Data`. // it means that actix-web has an issue or someone changes the type `Data`.
let data = req.app_data::<web::Data<Data>>().unwrap(); let data = req.app_data::<web::Data<Data>>().unwrap();

View File

@ -1,5 +1,5 @@
/// From https://docs.rs/actix-web/3.0.0-alpha.2/src/actix_web/middleware/normalize.rs.html#34 /// From https://docs.rs/actix-web/3.0.0-alpha.2/src/actix_web/middleware/normalize.rs.html#34
use actix_http::Error; use actix_web::http::Error;
use actix_service::{Service, Transform}; use actix_service::{Service, Transform};
use actix_web::{ use actix_web::{
dev::ServiceRequest, dev::ServiceRequest,

View File

@ -1,8 +1,7 @@
mod local_index_controller; pub mod actor_index_controller;
//mod local_index_controller;
mod updates; mod updates;
pub use local_index_controller::LocalIndexController;
use std::collections::HashMap; use std::collections::HashMap;
use std::num::NonZeroUsize; use std::num::NonZeroUsize;
use std::sync::Arc; use std::sync::Arc;
@ -13,6 +12,7 @@ use milli::Index;
use milli::update::{IndexDocumentsMethod, UpdateFormat, DocumentAdditionResult}; use milli::update::{IndexDocumentsMethod, UpdateFormat, DocumentAdditionResult};
use serde::{Serialize, Deserialize, de::Deserializer}; use serde::{Serialize, Deserialize, de::Deserializer};
use uuid::Uuid; use uuid::Uuid;
use actix_web::web::Payload;
pub use updates::{Processed, Processing, Failed}; pub use updates::{Processed, Processing, Failed};
@ -21,7 +21,6 @@ pub type UpdateStatus = updates::UpdateStatus<UpdateMeta, UpdateResult, String>;
#[derive(Debug, Serialize, Deserialize, Clone)] #[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct IndexMetadata { pub struct IndexMetadata {
pub uid: String,
uuid: Uuid, uuid: Uuid,
created_at: DateTime<Utc>, created_at: DateTime<Utc>,
updated_at: DateTime<Utc>, updated_at: DateTime<Utc>,
@ -114,6 +113,7 @@ pub struct IndexSettings {
/// be provided. This allows the implementer to define the behaviour of write accesses to the /// be provided. This allows the implementer to define the behaviour of write accesses to the
/// indices, and abstract the scheduling of the updates. The implementer must be able to provide an /// indices, and abstract the scheduling of the updates. The implementer must be able to provide an
/// instance of `IndexStore` /// instance of `IndexStore`
#[async_trait::async_trait]
pub trait IndexController { pub trait IndexController {
/* /*
@ -126,59 +126,47 @@ pub trait IndexController {
/// Perform document addition on the database. If the provided index does not exist, it will be /// Perform document addition on the database. If the provided index does not exist, it will be
/// created when the addition is applied to the index. /// created when the addition is applied to the index.
fn add_documents<S: AsRef<str>>( async fn add_documents(
&self, &self,
index: S, index: String,
method: IndexDocumentsMethod, method: IndexDocumentsMethod,
format: UpdateFormat, format: UpdateFormat,
data: &[u8], data: Payload,
primary_key: Option<String>, primary_key: Option<String>,
) -> anyhow::Result<UpdateStatus>; ) -> anyhow::Result<UpdateStatus>;
/// Clear all documents in the given index. /// Clear all documents in the given index.
fn clear_documents(&self, index: impl AsRef<str>) -> anyhow::Result<UpdateStatus>; fn clear_documents(&self, index: String) -> anyhow::Result<UpdateStatus>;
/// Delete all documents in `document_ids`. /// Delete all documents in `document_ids`.
fn delete_documents(&self, index: impl AsRef<str>, document_ids: Vec<String>) -> anyhow::Result<UpdateStatus>; fn delete_documents(&self, index: String, document_ids: Vec<String>) -> anyhow::Result<UpdateStatus>;
/// Updates an index settings. If the index does not exist, it will be created when the update /// Updates an index settings. If the index does not exist, it will be created when the update
/// is applied to the index. /// is applied to the index.
fn update_settings<S: AsRef<str>>(&self, index_uid: S, settings: Settings) -> anyhow::Result<UpdateStatus>; fn update_settings(&self, index_uid: String, settings: Settings) -> anyhow::Result<UpdateStatus>;
/// Create an index with the given `index_uid`. /// Create an index with the given `index_uid`.
fn create_index(&self, index_settings: IndexSettings) -> Result<IndexMetadata>; async fn create_index(&self, index_settings: IndexSettings) -> Result<IndexMetadata>;
/// Delete index with the given `index_uid`, attempting to close it beforehand. /// Delete index with the given `index_uid`, attempting to close it beforehand.
fn delete_index<S: AsRef<str>>(&self, index_uid: S) -> Result<()>; fn delete_index(&self, index_uid: String) -> Result<()>;
/// Swap two indexes, concretely, it simply swaps the index the names point to. /// Swap two indexes, concretely, it simply swaps the index the names point to.
fn swap_indices<S1: AsRef<str>, S2: AsRef<str>>(&self, index1_uid: S1, index2_uid: S2) -> Result<()>; fn swap_indices(&self, index1_uid: String, index2_uid: String) -> Result<()>;
/// Apply an update to the given index. This method can be called when an update is ready to be
/// processed
fn handle_update<S: AsRef<str>>(
&self,
_index: S,
_update_id: u64,
_meta: Processing<UpdateMeta>,
_content: &[u8]
) -> Result<Processed<UpdateMeta, UpdateResult>, Failed<UpdateMeta, String>> {
todo!()
}
/// Returns, if it exists, the `Index` with the povided name. /// Returns, if it exists, the `Index` with the povided name.
fn index(&self, name: impl AsRef<str>) -> anyhow::Result<Option<Arc<Index>>>; fn index(&self, name: String) -> anyhow::Result<Option<Arc<Index>>>;
/// Returns the udpate status an update /// Returns the udpate status an update
fn update_status(&self, index: impl AsRef<str>, id: u64) -> anyhow::Result<Option<UpdateStatus>>; fn update_status(&self, index: String, id: u64) -> anyhow::Result<Option<UpdateStatus>>;
/// Returns all the udpate status for an index /// Returns all the udpate status for an index
fn all_update_status(&self, index: impl AsRef<str>) -> anyhow::Result<Vec<UpdateStatus>>; fn all_update_status(&self, index: String) -> anyhow::Result<Vec<UpdateStatus>>;
/// List all the indexes /// List all the indexes
fn list_indexes(&self) -> anyhow::Result<Vec<IndexMetadata>>; fn list_indexes(&self) -> anyhow::Result<Vec<IndexMetadata>>;
fn update_index(&self, name: impl AsRef<str>, index_settings: IndexSettings) -> anyhow::Result<IndexMetadata>; fn update_index(&self, name: String, index_settings: IndexSettings) -> anyhow::Result<IndexMetadata>;
} }

View File

@ -1,4 +1,7 @@
#![allow(clippy::or_fun_call)] #![allow(clippy::or_fun_call)]
#![allow(unused_must_use)]
#![allow(unused_variables)]
#![allow(dead_code)]
pub mod data; pub mod data;
pub mod error; pub mod error;
@ -7,54 +10,5 @@ pub mod option;
pub mod routes; pub mod routes;
mod index_controller; mod index_controller;
use actix_http::Error;
use actix_service::ServiceFactory;
use actix_web::{dev, web, App};
pub use option::Opt; pub use option::Opt;
pub use self::data::Data; pub use self::data::Data;
use self::error::payload_error_handler;
pub fn create_app(
data: &Data,
enable_frontend: bool,
) -> App<
impl ServiceFactory<
Config = (),
Request = dev::ServiceRequest,
Response = dev::ServiceResponse<actix_http::body::Body>,
Error = Error,
InitError = (),
>,
actix_http::body::Body,
> {
let app = App::new()
.data(data.clone())
.app_data(
web::JsonConfig::default()
.limit(data.http_payload_size_limit())
.content_type(|_mime| true) // Accept all mime types
.error_handler(|err, _req| payload_error_handler(err).into()),
)
.app_data(
web::QueryConfig::default()
.error_handler(|err, _req| payload_error_handler(err).into())
)
.configure(routes::document::services)
.configure(routes::index::services)
.configure(routes::search::services)
.configure(routes::settings::services)
.configure(routes::stop_words::services)
.configure(routes::synonym::services)
.configure(routes::health::services)
.configure(routes::stats::services)
.configure(routes::key::services);
//.configure(routes::dump::services);
if enable_frontend {
app
.service(routes::load_html)
.service(routes::load_css)
} else {
app
}
}

View File

@ -1,11 +1,13 @@
use std::env; use std::env;
use actix_cors::Cors; use actix_cors::Cors;
use actix_web::{middleware, HttpServer}; use actix_web::{middleware, HttpServer, web, web::ServiceConfig};
use main_error::MainError; use main_error::MainError;
use meilisearch_http::helpers::NormalizePath; use meilisearch::{Data, Opt};
use meilisearch_http::{create_app, Data, Opt};
use structopt::StructOpt; use structopt::StructOpt;
use actix_web::App;
use meilisearch::error::payload_error_handler;
use actix_web::middleware::TrailingSlash;
//mod analytics; //mod analytics;
@ -74,9 +76,34 @@ async fn main() -> Result<(), MainError> {
print_launch_resume(&opt, &data); print_launch_resume(&opt, &data);
let enable_frontend = opt.env != "production"; let enable_frontend = opt.env != "production";
run_http(data, opt, enable_frontend).await?;
Ok(())
}
async fn run_http(data: Data, opt: Opt, enable_frontend: bool) -> Result<(), Box<dyn std::error::Error>> {
let http_server = HttpServer::new(move || { let http_server = HttpServer::new(move || {
create_app(&data, enable_frontend) let app = App::new()
.wrap( .configure(|c| configure_data(c, &data))
.configure(meilisearch::routes::document::services)
.configure(meilisearch::routes::index::services)
.configure(meilisearch::routes::search::services)
.configure(meilisearch::routes::settings::services)
.configure(meilisearch::routes::stop_words::services)
.configure(meilisearch::routes::synonym::services)
.configure(meilisearch::routes::health::services)
.configure(meilisearch::routes::stats::services)
.configure(meilisearch::routes::key::services);
//.configure(routes::dump::services);
let app = if enable_frontend {
app
.service(meilisearch::routes::load_html)
.service(meilisearch::routes::load_css)
} else {
app
};
app.wrap(
Cors::default() Cors::default()
.send_wildcard() .send_wildcard()
.allowed_headers(vec!["content-type", "x-meili-api-key"]) .allowed_headers(vec!["content-type", "x-meili-api-key"])
@ -84,7 +111,7 @@ async fn main() -> Result<(), MainError> {
) )
.wrap(middleware::Logger::default()) .wrap(middleware::Logger::default())
.wrap(middleware::Compress::default()) .wrap(middleware::Compress::default())
.wrap(NormalizePath) .wrap(middleware::NormalizePath::new(TrailingSlash::Trim))
}); });
if let Some(config) = opt.get_ssl_config()? { if let Some(config) = opt.get_ssl_config()? {
@ -95,10 +122,24 @@ async fn main() -> Result<(), MainError> {
} else { } else {
http_server.bind(opt.http_addr)?.run().await?; http_server.bind(opt.http_addr)?.run().await?;
} }
Ok(()) Ok(())
} }
fn configure_data(config: &mut ServiceConfig, data: &Data) {
config
.data(data.clone())
.app_data(
web::JsonConfig::default()
.limit(data.http_payload_size_limit())
.content_type(|_mime| true) // Accept all mime types
.error_handler(|err, _req| payload_error_handler(err).into()),
)
.app_data(
web::QueryConfig::default()
.error_handler(|err, _req| payload_error_handler(err).into())
);
}
pub fn print_launch_resume(opt: &Opt, data: &Data) { pub fn print_launch_resume(opt: &Opt, data: &Data) {
let ascii_name = r#" let ascii_name = r#"
888b d888 d8b 888 d8b .d8888b. 888 888b d888 d8b 888 d8b .d8888b. 888

View File

@ -3,7 +3,7 @@ use actix_web::{delete, get, post, put};
use actix_web::{web, HttpResponse}; use actix_web::{web, HttpResponse};
use indexmap::IndexMap; use indexmap::IndexMap;
use log::error; use log::error;
use milli::update::{IndexDocumentsMethod, UpdateFormat}; //use milli::update::{IndexDocumentsMethod, UpdateFormat};
use serde::Deserialize; use serde::Deserialize;
use serde_json::Value; use serde_json::Value;
@ -142,25 +142,26 @@ async fn add_documents_json(
params: web::Query<UpdateDocumentsQuery>, params: web::Query<UpdateDocumentsQuery>,
body: Payload, body: Payload,
) -> Result<HttpResponse, ResponseError> { ) -> Result<HttpResponse, ResponseError> {
let addition_result = data todo!()
.add_documents( //let addition_result = data
path.into_inner().index_uid, //.add_documents(
IndexDocumentsMethod::ReplaceDocuments, //path.into_inner().index_uid,
UpdateFormat::Json, //IndexDocumentsMethod::ReplaceDocuments,
body, //UpdateFormat::Json,
params.primary_key.clone(), //body,
).await; //params.primary_key.clone(),
//).await;
match addition_result { //match addition_result {
Ok(update) => { //Ok(update) => {
let value = serde_json::to_string(&update).unwrap(); //let value = serde_json::to_string(&update).unwrap();
let response = HttpResponse::Ok().body(value); //let response = HttpResponse::Ok().body(value);
Ok(response) //Ok(response)
} //}
Err(e) => { //Err(e) => {
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() }))) //Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
} //}
} //}
} }
@ -199,25 +200,26 @@ async fn update_documents(
params: web::Query<UpdateDocumentsQuery>, params: web::Query<UpdateDocumentsQuery>,
body: web::Payload, body: web::Payload,
) -> Result<HttpResponse, ResponseError> { ) -> Result<HttpResponse, ResponseError> {
let addition_result = data todo!()
.add_documents( //let addition_result = data
path.into_inner().index_uid, //.add_documents(
IndexDocumentsMethod::UpdateDocuments, //path.into_inner().index_uid,
UpdateFormat::Json, //IndexDocumentsMethod::UpdateDocuments,
body, //UpdateFormat::Json,
params.primary_key.clone(), //body,
).await; //params.primary_key.clone(),
//).await;
match addition_result { //match addition_result {
Ok(update) => { //Ok(update) => {
let value = serde_json::to_string(&update).unwrap(); //let value = serde_json::to_string(&update).unwrap();
let response = HttpResponse::Ok().body(value); //let response = HttpResponse::Ok().body(value);
Ok(response) //Ok(response)
} //}
Err(e) => { //Err(e) => {
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() }))) //Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
} //}
} //}
} }
#[post( #[post(
@ -229,20 +231,21 @@ async fn delete_documents(
path: web::Path<IndexParam>, path: web::Path<IndexParam>,
body: web::Json<Vec<Value>>, body: web::Json<Vec<Value>>,
) -> Result<HttpResponse, ResponseError> { ) -> Result<HttpResponse, ResponseError> {
let ids = body todo!()
.iter() //let ids = body
.map(|v| v.as_str().map(String::from).unwrap_or_else(|| v.to_string())) //.iter()
.collect(); //.map(|v| v.as_str().map(String::from).unwrap_or_else(|| v.to_string()))
//.collect();
match data.delete_documents(path.index_uid.clone(), ids).await { //match data.delete_documents(path.index_uid.clone(), ids).await {
Ok(result) => { //Ok(result) => {
let json = serde_json::to_string(&result).unwrap(); //let json = serde_json::to_string(&result).unwrap();
Ok(HttpResponse::Ok().body(json)) //Ok(HttpResponse::Ok().body(json))
} //}
Err(e) => { //Err(e) => {
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() }))) //Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
} //}
} //}
} }
#[delete("/indexes/{index_uid}/documents", wrap = "Authentication::Private")] #[delete("/indexes/{index_uid}/documents", wrap = "Authentication::Private")]
@ -250,13 +253,14 @@ async fn clear_all_documents(
data: web::Data<Data>, data: web::Data<Data>,
path: web::Path<IndexParam>, path: web::Path<IndexParam>,
) -> Result<HttpResponse, ResponseError> { ) -> Result<HttpResponse, ResponseError> {
match data.clear_documents(path.index_uid.clone()).await { todo!()
Ok(update) => { //match data.clear_documents(path.index_uid.clone()).await {
let json = serde_json::to_string(&update).unwrap(); //Ok(update) => {
Ok(HttpResponse::Ok().body(json)) //let json = serde_json::to_string(&update).unwrap();
} //Ok(HttpResponse::Ok().body(json))
Err(e) => { //}
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() }))) //Err(e) => {
} //Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
} //}
//}
} }

View File

@ -61,7 +61,7 @@ async fn create_index(
data: web::Data<Data>, data: web::Data<Data>,
body: web::Json<IndexCreateRequest>, body: web::Json<IndexCreateRequest>,
) -> Result<HttpResponse, ResponseError> { ) -> Result<HttpResponse, ResponseError> {
match data.create_index(&body.uid, body.primary_key.clone()) { match data.create_index(&body.uid, body.primary_key.clone()).await {
Ok(meta) => { Ok(meta) => {
let json = serde_json::to_string(&meta).unwrap(); let json = serde_json::to_string(&meta).unwrap();
Ok(HttpResponse::Ok().body(json)) Ok(HttpResponse::Ok().body(json))

View File

@ -19,7 +19,7 @@ struct KeysResponse {
#[get("/keys", wrap = "Authentication::Admin")] #[get("/keys", wrap = "Authentication::Admin")]
async fn list(data: web::Data<Data>) -> HttpResponse { async fn list(data: web::Data<Data>) -> HttpResponse {
let api_keys = data.api_keys.clone(); let api_keys = data.api_keys.clone();
HttpResponse::Ok().json(KeysResponse { HttpResponse::Ok().json(&KeysResponse {
private: api_keys.private, private: api_keys.private,
public: api_keys.public, public: api_keys.public,
}) })