mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-26 03:55:07 +08:00
update tokio and disable all routes
This commit is contained in:
parent
45d8f36f5e
commit
61ce749122
532
Cargo.lock
generated
532
Cargo.lock
generated
@ -12,8 +12,24 @@ dependencies = [
|
||||
"futures-sink",
|
||||
"log",
|
||||
"pin-project 0.4.27",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tokio 0.2.24",
|
||||
"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]]
|
||||
@ -22,27 +38,22 @@ version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "177837a10863f15ba8d3ae3ec12fac1099099529ed20083a27fdfe247381d0dc"
|
||||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-rt",
|
||||
"actix-service",
|
||||
"actix-utils",
|
||||
"actix-codec 0.3.0",
|
||||
"actix-rt 1.1.1",
|
||||
"actix-service 1.0.6",
|
||||
"actix-utils 2.0.0",
|
||||
"derive_more",
|
||||
"either",
|
||||
"futures-util",
|
||||
"http",
|
||||
"log",
|
||||
"rustls",
|
||||
"tokio-rustls",
|
||||
"trust-dns-proto",
|
||||
"trust-dns-resolver",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-cors"
|
||||
version = "0.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f3a3d5493dbc9b8769fe88c030d057ef8d2edc5728e5e26267780e8fc5db0be"
|
||||
version = "0.5.4"
|
||||
dependencies = [
|
||||
"actix-web",
|
||||
"derive_more",
|
||||
@ -58,28 +69,25 @@ version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "452299e87817ae5673910e53c243484ca38be3828db819b6011736fc6982e874"
|
||||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-codec 0.3.0",
|
||||
"actix-connect",
|
||||
"actix-rt",
|
||||
"actix-service",
|
||||
"actix-rt 1.1.1",
|
||||
"actix-service 1.0.6",
|
||||
"actix-threadpool",
|
||||
"actix-tls",
|
||||
"actix-utils",
|
||||
"actix-utils 2.0.0",
|
||||
"base64 0.13.0",
|
||||
"bitflags",
|
||||
"brotli2",
|
||||
"bytes 0.5.6",
|
||||
"cookie",
|
||||
"copyless",
|
||||
"derive_more",
|
||||
"either",
|
||||
"encoding_rs",
|
||||
"flate2",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"fxhash",
|
||||
"h2",
|
||||
"h2 0.2.7",
|
||||
"http",
|
||||
"httparse",
|
||||
"indexmap",
|
||||
@ -100,6 +108,52 @@ dependencies = [
|
||||
"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]]
|
||||
name = "actix-macros"
|
||||
version = "0.1.3"
|
||||
@ -111,10 +165,20 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-router"
|
||||
version = "0.2.5"
|
||||
name = "actix-macros"
|
||||
version = "0.2.0"
|
||||
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 = [
|
||||
"bytestring",
|
||||
"http",
|
||||
@ -129,33 +193,42 @@ version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227"
|
||||
dependencies = [
|
||||
"actix-macros",
|
||||
"actix-macros 0.1.3",
|
||||
"actix-threadpool",
|
||||
"copyless",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"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]]
|
||||
name = "actix-server"
|
||||
version = "1.0.4"
|
||||
version = "2.0.0-beta.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45407e6e672ca24784baa667c5d32ef109ccdd8d5e0b5ebb9ef8a67f4dfb708e"
|
||||
checksum = "a99198727204a48f82559c18e4b0ba3197b97d5f4576a32bdbef371f3b4599c1"
|
||||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-rt",
|
||||
"actix-service",
|
||||
"actix-utils",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"actix-codec 0.4.0-beta.1",
|
||||
"actix-rt 2.1.0",
|
||||
"actix-service 2.0.0-beta.4",
|
||||
"actix-utils 3.0.0-beta.2",
|
||||
"futures-core",
|
||||
"log",
|
||||
"mio",
|
||||
"mio-uds",
|
||||
"mio 0.7.9",
|
||||
"num_cpus",
|
||||
"slab",
|
||||
"socket2",
|
||||
"tokio 1.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -169,17 +242,13 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-testing"
|
||||
version = "1.0.1"
|
||||
name = "actix-service"
|
||||
version = "2.0.0-beta.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47239ca38799ab74ee6a8a94d1ce857014b2ac36f242f70f3f75a66f691e791c"
|
||||
checksum = "ca9756f4d32984ac454ae3155a276f6be69b424197bd3f0ca3c87cde72f41d63"
|
||||
dependencies = [
|
||||
"actix-macros",
|
||||
"actix-rt",
|
||||
"actix-server",
|
||||
"actix-service",
|
||||
"log",
|
||||
"socket2",
|
||||
"futures-core",
|
||||
"pin-project-lite 0.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -199,18 +268,21 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "actix-tls"
|
||||
version = "2.0.0"
|
||||
version = "3.0.0-beta.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24789b7d7361cf5503a504ebe1c10806896f61e96eca9a7350e23001aca715fb"
|
||||
checksum = "d2b1455e3f7a26d40cfc1080b571f41e8165e5a88e937ed579f7a4b3d55b0370"
|
||||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-service",
|
||||
"actix-utils",
|
||||
"futures-util",
|
||||
"rustls",
|
||||
"tokio-rustls",
|
||||
"webpki",
|
||||
"webpki-roots",
|
||||
"actix-codec 0.4.0-beta.1",
|
||||
"actix-rt 2.1.0",
|
||||
"actix-service 2.0.0-beta.4",
|
||||
"actix-utils 3.0.0-beta.2",
|
||||
"derive_more",
|
||||
"futures-core",
|
||||
"http",
|
||||
"log",
|
||||
"tokio-rustls 0.22.0",
|
||||
"tokio-util 0.6.3",
|
||||
"webpki-roots 0.21.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -219,9 +291,9 @@ version = "2.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2e9022dec56632d1d7979e59af14f0597a28a830a9c1c7fec8b2327eb9f16b5a"
|
||||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-rt",
|
||||
"actix-service",
|
||||
"actix-codec 0.3.0",
|
||||
"actix-rt 1.1.1",
|
||||
"actix-service 1.0.6",
|
||||
"bitflags",
|
||||
"bytes 0.5.6",
|
||||
"either",
|
||||
@ -234,50 +306,63 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-web"
|
||||
version = "3.3.2"
|
||||
name = "actix-utils"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e641d4a172e7faa0862241a20ff4f1f5ab0ab7c279f00c2d4587b77483477b86"
|
||||
checksum = "458795e09a29bc5557604f9ff6f32236fd0ee457d631672e4ec8f6a0103bb292"
|
||||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-http",
|
||||
"actix-macros",
|
||||
"actix-codec 0.4.0-beta.1",
|
||||
"actix-rt 2.1.0",
|
||||
"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-rt",
|
||||
"actix-rt 2.1.0",
|
||||
"actix-server",
|
||||
"actix-service",
|
||||
"actix-testing",
|
||||
"actix-threadpool",
|
||||
"actix-service 2.0.0-beta.4",
|
||||
"actix-tls",
|
||||
"actix-utils",
|
||||
"actix-utils 3.0.0-beta.2",
|
||||
"actix-web-codegen",
|
||||
"ahash 0.7.0",
|
||||
"awc",
|
||||
"bytes 0.5.6",
|
||||
"bytes 1.0.1",
|
||||
"derive_more",
|
||||
"either",
|
||||
"encoding_rs",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"fxhash",
|
||||
"log",
|
||||
"mime",
|
||||
"pin-project 1.0.2",
|
||||
"regex",
|
||||
"rustls",
|
||||
"rustls 0.19.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"smallvec",
|
||||
"socket2",
|
||||
"time 0.2.23",
|
||||
"tinyvec",
|
||||
"url",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "actix-web-codegen"
|
||||
version = "0.4.0"
|
||||
version = "0.5.0-beta.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ad26f77093333e0e7c6ffe54ebe3582d908a104e448723eec6d43d08b07143fb"
|
||||
checksum = "8313dc4cbcae1785a7f14c3dfb7dfeb25fe96a03b20e5c38fe026786def5aa70"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -305,6 +390,17 @@ version = "0.3.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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]]
|
||||
name = "aho-corasick"
|
||||
version = "0.7.15"
|
||||
@ -348,7 +444,7 @@ dependencies = [
|
||||
"futures-core",
|
||||
"memchr",
|
||||
"pin-project-lite 0.1.11",
|
||||
"tokio",
|
||||
"tokio 0.2.24",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -381,24 +477,24 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a"
|
||||
|
||||
[[package]]
|
||||
name = "awc"
|
||||
version = "2.0.3"
|
||||
version = "3.0.0-beta.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b381e490e7b0cfc37ebc54079b0413d8093ef43d14a4e4747083f7fa47a9e691"
|
||||
checksum = "da7225ad81fbad09ef56ccc61e0688abe8494a68722c5d0df5e2fc8b724a200b"
|
||||
dependencies = [
|
||||
"actix-codec",
|
||||
"actix-http",
|
||||
"actix-rt",
|
||||
"actix-service",
|
||||
"actix-codec 0.4.0-beta.1",
|
||||
"actix-http 3.0.0-beta.3",
|
||||
"actix-rt 2.1.0",
|
||||
"actix-service 2.0.0-beta.4",
|
||||
"base64 0.13.0",
|
||||
"bytes 0.5.6",
|
||||
"bytes 1.0.1",
|
||||
"cfg-if 1.0.0",
|
||||
"derive_more",
|
||||
"futures-core",
|
||||
"log",
|
||||
"mime",
|
||||
"percent-encoding",
|
||||
"rand 0.7.3",
|
||||
"rustls",
|
||||
"rand 0.8.3",
|
||||
"rustls 0.19.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
@ -563,12 +659,18 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0dcbc35f504eb6fc275a6d20e4ebcda18cf50d40ba6fabff8c711fa16cb3b16"
|
||||
|
||||
[[package]]
|
||||
name = "bytestring"
|
||||
version = "0.1.5"
|
||||
name = "bytes"
|
||||
version = "1.0.1"
|
||||
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 = [
|
||||
"bytes 0.5.6",
|
||||
"bytes 1.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1171,8 +1273,28 @@ dependencies = [
|
||||
"http",
|
||||
"indexmap",
|
||||
"slab",
|
||||
"tokio",
|
||||
"tokio-util",
|
||||
"tokio 0.2.24",
|
||||
"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-futures",
|
||||
]
|
||||
@ -1183,7 +1305,7 @@ version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "96282e96bfcd3da0d3aa9938bedf1e50df3269b6db08b4876d2da0bb1a0841cf"
|
||||
dependencies = [
|
||||
"ahash",
|
||||
"ahash 0.3.8",
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
@ -1262,11 +1384,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.2"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "84129d298a6d57d246960ff8eb831ca4af3f96d29e2e28848dae275408658e26"
|
||||
checksum = "7245cd7449cc792608c3c8a9eaf69bd4eabbabf802713748fd739c98b82f0747"
|
||||
dependencies = [
|
||||
"bytes 0.5.6",
|
||||
"bytes 1.0.1",
|
||||
"fnv",
|
||||
"itoa",
|
||||
]
|
||||
@ -1324,7 +1446,7 @@ dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2",
|
||||
"h2 0.2.7",
|
||||
"http",
|
||||
"http-body",
|
||||
"httparse",
|
||||
@ -1332,7 +1454,7 @@ dependencies = [
|
||||
"itoa",
|
||||
"pin-project 1.0.2",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tokio 0.2.24",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"want",
|
||||
@ -1348,9 +1470,9 @@ dependencies = [
|
||||
"futures-util",
|
||||
"hyper",
|
||||
"log",
|
||||
"rustls",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"rustls 0.18.1",
|
||||
"tokio 0.2.24",
|
||||
"tokio-rustls 0.14.1",
|
||||
"webpki",
|
||||
]
|
||||
|
||||
@ -1537,9 +1659,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.81"
|
||||
version = "0.2.86"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1482821306169ec4d07f6aca392a4681f66c75c9918aa49641a2595db64053cb"
|
||||
checksum = "b7282d924be3275cec7f6756ff4121987bc6481325397dde6ba3e7802b1a8b1c"
|
||||
|
||||
[[package]]
|
||||
name = "linked-hash-map"
|
||||
@ -1610,24 +1732,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ffc5c5338469d4d3ea17d269fa8ea3512ad247247c30bd2df69e68309ed0a08"
|
||||
|
||||
[[package]]
|
||||
name = "meilisearch-error"
|
||||
version = "0.19.0"
|
||||
dependencies = [
|
||||
"actix-http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "meilisearch-http"
|
||||
name = "meilisearch"
|
||||
version = "0.17.0"
|
||||
dependencies = [
|
||||
"actix-cors",
|
||||
"actix-http",
|
||||
"actix-rt",
|
||||
"actix-service",
|
||||
"actix-service 1.0.6",
|
||||
"actix-web",
|
||||
"anyhow",
|
||||
"assert-json-diff",
|
||||
"async-compression",
|
||||
"async-trait",
|
||||
"byte-unit",
|
||||
"bytes 0.6.0",
|
||||
"chrono",
|
||||
@ -1656,7 +1770,7 @@ dependencies = [
|
||||
"rand 0.7.3",
|
||||
"rayon",
|
||||
"regex",
|
||||
"rustls",
|
||||
"rustls 0.19.0",
|
||||
"sentry",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@ -1668,11 +1782,20 @@ dependencies = [
|
||||
"tar",
|
||||
"tempdir",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"thiserror",
|
||||
"tokio 0.2.24",
|
||||
"tokio 1.2.0",
|
||||
"uuid",
|
||||
"vergen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "meilisearch-error"
|
||||
version = "0.19.0"
|
||||
dependencies = [
|
||||
"actix-http 2.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "meilisearch-tokenizer"
|
||||
version = "0.1.1"
|
||||
@ -1799,14 +1922,15 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mio-named-pipes"
|
||||
version = "0.1.7"
|
||||
name = "mio"
|
||||
version = "0.7.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0840c1c50fd55e521b247f949c241c9997709f23bd7f023b9762cd561e935656"
|
||||
checksum = "a5dede4e2065b3842b8b0af444119f3aa331cc7cc2dd20388bfb0f5d5a38823a"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
"mio",
|
||||
"miow 0.3.6",
|
||||
"ntapi",
|
||||
"winapi 0.3.9",
|
||||
]
|
||||
|
||||
@ -1818,7 +1942,7 @@ checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0"
|
||||
dependencies = [
|
||||
"iovec",
|
||||
"libc",
|
||||
"mio",
|
||||
"mio 0.6.23",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -1866,6 +1990,15 @@ dependencies = [
|
||||
"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]]
|
||||
name = "num-integer"
|
||||
version = "0.1.44"
|
||||
@ -2215,12 +2348,24 @@ checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03"
|
||||
dependencies = [
|
||||
"getrandom 0.1.15",
|
||||
"libc",
|
||||
"rand_chacha",
|
||||
"rand_chacha 0.2.2",
|
||||
"rand_core 0.5.1",
|
||||
"rand_hc",
|
||||
"rand_hc 0.2.0",
|
||||
"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]]
|
||||
name = "rand_chacha"
|
||||
version = "0.2.2"
|
||||
@ -2231,6 +2376,16 @@ dependencies = [
|
||||
"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]]
|
||||
name = "rand_core"
|
||||
version = "0.3.1"
|
||||
@ -2255,6 +2410,15 @@ dependencies = [
|
||||
"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]]
|
||||
name = "rand_hc"
|
||||
version = "0.2.0"
|
||||
@ -2264,6 +2428,15 @@ dependencies = [
|
||||
"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]]
|
||||
name = "rand_pcg"
|
||||
version = "0.2.1"
|
||||
@ -2381,17 +2554,17 @@ dependencies = [
|
||||
"mime_guess",
|
||||
"percent-encoding",
|
||||
"pin-project-lite 0.2.0",
|
||||
"rustls",
|
||||
"rustls 0.18.1",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tokio 0.2.24",
|
||||
"tokio-rustls 0.14.1",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"webpki-roots",
|
||||
"webpki-roots 0.20.0",
|
||||
"winreg 0.7.0",
|
||||
]
|
||||
|
||||
@ -2457,6 +2630,19 @@ dependencies = [
|
||||
"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]]
|
||||
name = "ryu"
|
||||
version = "1.0.5"
|
||||
@ -2680,9 +2866,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.5.1"
|
||||
version = "1.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae524f056d7d770e174287294f562e95044c68e88dec909a00d2094805db9d75"
|
||||
checksum = "fe0f37c9e8f3c5a4a66ad655a93c74daac4ad00c441533bf5c6e7990bb42604e"
|
||||
|
||||
[[package]]
|
||||
name = "snap"
|
||||
@ -2883,18 +3069,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.22"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e9ae34b84616eedaaf1e9dd6026dbe00dcafa92aa0c8077cb69df1fcfe5e53e"
|
||||
checksum = "e0f4a65597094d4483ddaed134f409b2cb7c1beccf25201a9f73c719254fa98e"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.22"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ba20f23e85b10754cd195504aebf6a27e2e6cbe28c17778a0c930724628dd56"
|
||||
checksum = "7765189610d8241a44529806d6fd1f2e0a08734313a35d5b3a556f92b381f3c0"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -2996,14 +3182,33 @@ dependencies = [
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"memchr",
|
||||
"mio",
|
||||
"mio-named-pipes",
|
||||
"mio 0.6.23",
|
||||
"mio-uds",
|
||||
"num_cpus",
|
||||
"pin-project-lite 0.1.11",
|
||||
"signal-hook-registry",
|
||||
"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",
|
||||
]
|
||||
|
||||
@ -3018,6 +3223,17 @@ dependencies = [
|
||||
"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]]
|
||||
name = "tokio-rustls"
|
||||
version = "0.14.1"
|
||||
@ -3025,8 +3241,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e12831b255bcfa39dc0436b01e19fea231a37db570686c06ee72c423479f889a"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"rustls",
|
||||
"tokio",
|
||||
"rustls 0.18.1",
|
||||
"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",
|
||||
]
|
||||
|
||||
@ -3041,7 +3268,21 @@ dependencies = [
|
||||
"futures-sink",
|
||||
"log",
|
||||
"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]]
|
||||
@ -3097,7 +3338,7 @@ dependencies = [
|
||||
"rand 0.7.3",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio 0.2.24",
|
||||
"url",
|
||||
]
|
||||
|
||||
@ -3117,7 +3358,7 @@ dependencies = [
|
||||
"resolv-conf",
|
||||
"smallvec",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
"tokio 0.2.24",
|
||||
"trust-dns-proto",
|
||||
]
|
||||
|
||||
@ -3369,6 +3610,15 @@ dependencies = [
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "webpki-roots"
|
||||
version = "0.21.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "82015b7e0b8bad8185994674a13a93306bea76cf5a16c5a181382fd3a5ec2376"
|
||||
dependencies = [
|
||||
"webpki",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "whatlang"
|
||||
version = "0.9.0"
|
||||
|
16
Cargo.toml
16
Cargo.toml
@ -3,7 +3,7 @@ authors = ["Quentin de Quelen <quentin@dequelen.me>", "Clément Renault <clement
|
||||
description = "MeiliSearch HTTP server"
|
||||
edition = "2018"
|
||||
license = "MIT"
|
||||
name = "meilisearch-http"
|
||||
name = "meilisearch"
|
||||
version = "0.17.0"
|
||||
[[bin]]
|
||||
name = "meilisearch"
|
||||
@ -13,11 +13,11 @@ path = "src/main.rs"
|
||||
vergen = "3.1.0"
|
||||
|
||||
[dependencies]
|
||||
actix-cors = "0.5.3"
|
||||
actix-http = "2"
|
||||
actix-rt = "1"
|
||||
actix-cors = { path = "../actix-extras/actix-cors" }
|
||||
#actix-http = "2"
|
||||
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"
|
||||
async-compression = { version = "0.3.6", features = ["gzip", "tokio-02"] }
|
||||
byte-unit = { version = "4.0.9", default-features = false, features = ["std"] }
|
||||
@ -44,7 +44,7 @@ once_cell = "1.5.2"
|
||||
rand = "0.7.3"
|
||||
rayon = "1.5.0"
|
||||
regex = "1.4.2"
|
||||
rustls = "0.18"
|
||||
rustls = "0.19"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = { version = "1.0.59", features = ["preserve_order"] }
|
||||
sha2 = "0.9.1"
|
||||
@ -53,11 +53,13 @@ slice-group-by = "0.2.6"
|
||||
structopt = "0.3.20"
|
||||
tar = "0.4.29"
|
||||
tempfile = "3.1.0"
|
||||
tokio = { version = "0.2", features = ["full"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
dashmap = "4.0.2"
|
||||
uuid = "0.8.2"
|
||||
itertools = "0.10.0"
|
||||
either = "1.6.1"
|
||||
async-trait = "0.1.42"
|
||||
thiserror = "1.0.24"
|
||||
|
||||
[dependencies.sentry]
|
||||
default-features = false
|
||||
|
@ -9,7 +9,8 @@ use std::sync::Arc;
|
||||
|
||||
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;
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -27,7 +28,7 @@ impl Deref for Data {
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct DataInner {
|
||||
pub index_controller: Arc<LocalIndexController>,
|
||||
pub index_controller: Arc<dyn IndexController + Send + Sync>,
|
||||
pub api_keys: ApiKeys,
|
||||
options: Opt,
|
||||
}
|
||||
@ -59,14 +60,9 @@ impl ApiKeys {
|
||||
impl Data {
|
||||
pub fn new(options: Opt) -> anyhow::Result<Data> {
|
||||
let path = options.db_path.clone();
|
||||
let indexer_opts = options.indexer_options.clone();
|
||||
//let indexer_opts = options.indexer_options.clone();
|
||||
create_dir_all(&path)?;
|
||||
let index_controller = LocalIndexController::new(
|
||||
&path,
|
||||
indexer_opts,
|
||||
options.max_mdb_size.get_bytes(),
|
||||
options.max_udb_size.get_bytes(),
|
||||
)?;
|
||||
let index_controller = ActorIndexController::new();
|
||||
let index_controller = Arc::new(index_controller);
|
||||
|
||||
let mut api_keys = ApiKeys {
|
||||
@ -85,7 +81,7 @@ impl Data {
|
||||
|
||||
pub fn settings<S: AsRef<str>>(&self, index_uid: S) -> anyhow::Result<Settings> {
|
||||
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()))?;
|
||||
|
||||
let txn = index.read_txn()?;
|
||||
@ -119,19 +115,20 @@ impl Data {
|
||||
}
|
||||
|
||||
pub fn index(&self, name: impl AsRef<str>) -> anyhow::Result<Option<IndexMetadata>> {
|
||||
Ok(self
|
||||
.list_indexes()?
|
||||
.into_iter()
|
||||
.find(|i| i.uid == name.as_ref()))
|
||||
todo!()
|
||||
//Ok(self
|
||||
//.list_indexes()?
|
||||
//.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 {
|
||||
name: Some(name.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)
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ use std::collections::{HashSet, BTreeMap};
|
||||
use std::mem;
|
||||
use std::time::Instant;
|
||||
|
||||
use anyhow::{bail, Context};
|
||||
use anyhow::bail;
|
||||
use either::Either;
|
||||
use heed::RoTxn;
|
||||
use meilisearch_tokenizer::{Analyzer, AnalyzerConfig};
|
||||
@ -11,7 +11,6 @@ use serde::{Deserialize, Serialize};
|
||||
use serde_json::{Map, Value};
|
||||
|
||||
use super::Data;
|
||||
use crate::index_controller::IndexController;
|
||||
|
||||
pub const DEFAULT_SEARCH_LIMIT: usize = 20;
|
||||
|
||||
@ -202,107 +201,110 @@ impl<'a, A: AsRef<[u8]>> Highlighter<'a, A> {
|
||||
impl Data {
|
||||
pub fn search<S: AsRef<str>>(
|
||||
&self,
|
||||
index: S,
|
||||
search_query: SearchQuery,
|
||||
_index: S,
|
||||
_search_query: SearchQuery,
|
||||
) -> anyhow::Result<SearchResult> {
|
||||
match self.index_controller.index(&index)? {
|
||||
Some(index) => Ok(search_query.perform(index)?),
|
||||
None => bail!("index {:?} doesn't exists", index.as_ref()),
|
||||
}
|
||||
todo!()
|
||||
//match self.index_controller.index(&index)? {
|
||||
//Some(index) => Ok(search_query.perform(index)?),
|
||||
//None => bail!("index {:?} doesn't exists", index.as_ref()),
|
||||
//}
|
||||
}
|
||||
|
||||
pub async fn retrieve_documents<S>(
|
||||
&self,
|
||||
index: impl AsRef<str> + Send + Sync + 'static,
|
||||
offset: usize,
|
||||
limit: usize,
|
||||
attributes_to_retrieve: Option<Vec<S>>,
|
||||
_index: String,
|
||||
_offset: usize,
|
||||
_limit: usize,
|
||||
_attributes_to_retrieve: Option<Vec<S>>,
|
||||
) -> anyhow::Result<Vec<Map<String, Value>>>
|
||||
where
|
||||
S: AsRef<str> + Send + Sync + 'static,
|
||||
{
|
||||
let index_controller = self.index_controller.clone();
|
||||
let documents: anyhow::Result<_> = tokio::task::spawn_blocking(move || {
|
||||
let index = index_controller
|
||||
.index(&index)?
|
||||
.with_context(|| format!("Index {:?} doesn't exist", index.as_ref()))?;
|
||||
todo!()
|
||||
//let index_controller = self.index_controller.clone();
|
||||
//let documents: anyhow::Result<_> = tokio::task::spawn_blocking(move || {
|
||||
//let index = index_controller
|
||||
//.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 {
|
||||
Some(attrs) => attrs
|
||||
.iter()
|
||||
.filter_map(|f| fields_ids_map.id(f.as_ref()))
|
||||
.collect::<Vec<_>>(),
|
||||
None => fields_ids_map.iter().map(|(id, _)| id).collect(),
|
||||
};
|
||||
//let attributes_to_retrieve_ids = match attributes_to_retrieve {
|
||||
//Some(attrs) => attrs
|
||||
//.iter()
|
||||
//.filter_map(|f| fields_ids_map.id(f.as_ref()))
|
||||
//.collect::<Vec<_>>(),
|
||||
//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 {
|
||||
let (_id, obkv) = entry?;
|
||||
let object = obkv_to_json(&attributes_to_retrieve_ids, &fields_ids_map, obkv)?;
|
||||
documents.push(object);
|
||||
}
|
||||
//for entry in iter {
|
||||
//let (_id, obkv) = entry?;
|
||||
//let object = obkv_to_json(&attributes_to_retrieve_ids, &fields_ids_map, obkv)?;
|
||||
//documents.push(object);
|
||||
//}
|
||||
|
||||
Ok(documents)
|
||||
})
|
||||
.await?;
|
||||
documents
|
||||
//Ok(documents)
|
||||
//})
|
||||
//.await?;
|
||||
//documents
|
||||
}
|
||||
|
||||
pub async fn retrieve_document<S>(
|
||||
&self,
|
||||
index: impl AsRef<str> + Sync + Send + 'static,
|
||||
document_id: impl AsRef<str> + Sync + Send + 'static,
|
||||
attributes_to_retrieve: Option<Vec<S>>,
|
||||
_index: impl AsRef<str> + Sync + Send + 'static,
|
||||
_document_id: impl AsRef<str> + Sync + Send + 'static,
|
||||
_attributes_to_retrieve: Option<Vec<S>>,
|
||||
) -> anyhow::Result<Map<String, Value>>
|
||||
where
|
||||
S: AsRef<str> + Sync + Send + 'static,
|
||||
{
|
||||
let index_controller = self.index_controller.clone();
|
||||
let document: anyhow::Result<_> = tokio::task::spawn_blocking(move || {
|
||||
let index = index_controller
|
||||
.index(&index)?
|
||||
.with_context(|| format!("Index {:?} doesn't exist", index.as_ref()))?;
|
||||
let txn = index.read_txn()?;
|
||||
todo!()
|
||||
//let index_controller = self.index_controller.clone();
|
||||
//let document: anyhow::Result<_> = tokio::task::spawn_blocking(move || {
|
||||
//let index = index_controller
|
||||
//.index(&index)?
|
||||
//.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 {
|
||||
Some(attrs) => attrs
|
||||
.iter()
|
||||
.filter_map(|f| fields_ids_map.id(f.as_ref()))
|
||||
.collect::<Vec<_>>(),
|
||||
None => fields_ids_map.iter().map(|(id, _)| id).collect(),
|
||||
};
|
||||
//let attributes_to_retrieve_ids = match attributes_to_retrieve {
|
||||
//Some(attrs) => attrs
|
||||
//.iter()
|
||||
//.filter_map(|f| fields_ids_map.id(f.as_ref()))
|
||||
//.collect::<Vec<_>>(),
|
||||
//None => fields_ids_map.iter().map(|(id, _)| id).collect(),
|
||||
//};
|
||||
|
||||
let internal_id = index
|
||||
.external_documents_ids(&txn)?
|
||||
.get(document_id.as_ref().as_bytes())
|
||||
.with_context(|| format!("Document with id {} not found", document_id.as_ref()))?;
|
||||
//let internal_id = index
|
||||
//.external_documents_ids(&txn)?
|
||||
//.get(document_id.as_ref().as_bytes())
|
||||
//.with_context(|| format!("Document with id {} not found", document_id.as_ref()))?;
|
||||
|
||||
let document = index
|
||||
.documents(&txn, std::iter::once(internal_id))?
|
||||
.into_iter()
|
||||
.next()
|
||||
.map(|(_, d)| d);
|
||||
//let document = index
|
||||
//.documents(&txn, std::iter::once(internal_id))?
|
||||
//.into_iter()
|
||||
//.next()
|
||||
//.map(|(_, d)| d);
|
||||
|
||||
match document {
|
||||
Some(document) => Ok(obkv_to_json(
|
||||
&attributes_to_retrieve_ids,
|
||||
&fields_ids_map,
|
||||
document,
|
||||
)?),
|
||||
None => bail!("Document with id {} not found", document_id.as_ref()),
|
||||
}
|
||||
})
|
||||
.await?;
|
||||
document
|
||||
//match document {
|
||||
//Some(document) => Ok(obkv_to_json(
|
||||
//&attributes_to_retrieve_ids,
|
||||
//&fields_ids_map,
|
||||
//document,
|
||||
//)?),
|
||||
//None => bail!("Document with id {} not found", document_id.as_ref()),
|
||||
//}
|
||||
//})
|
||||
//.await?;
|
||||
//document
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,13 @@
|
||||
use std::ops::Deref;
|
||||
|
||||
use async_compression::tokio_02::write::GzipEncoder;
|
||||
use futures_util::stream::StreamExt;
|
||||
use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
||||
use tokio::io::AsyncWriteExt;
|
||||
//use async_compression::tokio_02::write::GzipEncoder;
|
||||
//use futures_util::stream::StreamExt;
|
||||
//use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
||||
//use tokio::io::AsyncWriteExt;
|
||||
use actix_web::web::Payload;
|
||||
|
||||
use crate::index_controller::UpdateStatus;
|
||||
use crate::index_controller::{IndexController, Settings, IndexSettings, IndexMetadata};
|
||||
use crate::index_controller::{Settings, IndexMetadata};
|
||||
use super::Data;
|
||||
|
||||
impl Data {
|
||||
@ -15,88 +16,68 @@ impl Data {
|
||||
index: impl AsRef<str> + Send + Sync + 'static,
|
||||
method: IndexDocumentsMethod,
|
||||
format: UpdateFormat,
|
||||
mut stream: impl futures::Stream<Item=Result<B, E>> + Unpin,
|
||||
stream: Payload,
|
||||
primary_key: Option<String>,
|
||||
) -> anyhow::Result<UpdateStatus>
|
||||
where
|
||||
B: Deref<Target = [u8]>,
|
||||
E: std::error::Error + Send + Sync + 'static,
|
||||
{
|
||||
let file = tokio::task::spawn_blocking(tempfile::tempfile).await?;
|
||||
let file = tokio::fs::File::from_std(file?);
|
||||
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())
|
||||
let update_status = self.index_controller.add_documents(index.as_ref().to_string(), method, format, stream, primary_key).await?;
|
||||
Ok(update_status)
|
||||
}
|
||||
|
||||
pub async fn update_settings(
|
||||
&self,
|
||||
index: impl AsRef<str> + Send + Sync + 'static,
|
||||
settings: Settings
|
||||
_index: impl AsRef<str> + Send + Sync + 'static,
|
||||
_settings: Settings
|
||||
) -> anyhow::Result<UpdateStatus> {
|
||||
let index_controller = self.index_controller.clone();
|
||||
let update = tokio::task::spawn_blocking(move || index_controller.update_settings(index, settings)).await??;
|
||||
Ok(update.into())
|
||||
todo!()
|
||||
//let index_controller = self.index_controller.clone();
|
||||
//let update = tokio::task::spawn_blocking(move || index_controller.update_settings(index, settings)).await??;
|
||||
//Ok(update.into())
|
||||
}
|
||||
|
||||
pub async fn clear_documents(
|
||||
&self,
|
||||
index: impl AsRef<str> + Sync + Send + 'static,
|
||||
_index: impl AsRef<str> + Sync + Send + 'static,
|
||||
) -> anyhow::Result<UpdateStatus> {
|
||||
let index_controller = self.index_controller.clone();
|
||||
let update = tokio::task::spawn_blocking(move || index_controller.clear_documents(index)).await??;
|
||||
Ok(update.into())
|
||||
todo!()
|
||||
//let index_controller = self.index_controller.clone();
|
||||
//let update = tokio::task::spawn_blocking(move || index_controller.clear_documents(index)).await??;
|
||||
//Ok(update.into())
|
||||
}
|
||||
|
||||
pub async fn delete_documents(
|
||||
&self,
|
||||
index: impl AsRef<str> + Sync + Send + 'static,
|
||||
document_ids: Vec<String>,
|
||||
_index: impl AsRef<str> + Sync + Send + 'static,
|
||||
_document_ids: Vec<String>,
|
||||
) -> anyhow::Result<UpdateStatus> {
|
||||
let index_controller = self.index_controller.clone();
|
||||
let update = tokio::task::spawn_blocking(move || index_controller.delete_documents(index, document_ids)).await??;
|
||||
Ok(update.into())
|
||||
todo!()
|
||||
//let index_controller = self.index_controller.clone();
|
||||
//let update = tokio::task::spawn_blocking(move || index_controller.delete_documents(index, document_ids)).await??;
|
||||
//Ok(update.into())
|
||||
}
|
||||
|
||||
pub async fn delete_index(
|
||||
&self,
|
||||
index: impl AsRef<str> + Send + Sync + 'static,
|
||||
_index: impl AsRef<str> + Send + Sync + 'static,
|
||||
) -> anyhow::Result<()> {
|
||||
let index_controller = self.index_controller.clone();
|
||||
tokio::task::spawn_blocking(move || { index_controller.delete_index(index) }).await??;
|
||||
Ok(())
|
||||
todo!()
|
||||
//let index_controller = self.index_controller.clone();
|
||||
//tokio::task::spawn_blocking(move || { index_controller.delete_index(index) }).await??;
|
||||
//Ok(())
|
||||
}
|
||||
|
||||
#[inline]
|
||||
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>> {
|
||||
self.index_controller.all_update_status(index)
|
||||
todo!()
|
||||
//self.index_controller.all_update_status(index)
|
||||
}
|
||||
|
||||
pub fn update_index(
|
||||
@ -105,11 +86,12 @@ impl Data {
|
||||
primary_key: Option<impl AsRef<str>>,
|
||||
new_name: Option<impl AsRef<str>>
|
||||
) -> anyhow::Result<IndexMetadata> {
|
||||
let settings = IndexSettings {
|
||||
name: new_name.map(|s| s.as_ref().to_string()),
|
||||
primary_key: primary_key.map(|s| s.as_ref().to_string()),
|
||||
};
|
||||
todo!()
|
||||
//let settings = IndexSettings {
|
||||
//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)
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,8 @@
|
||||
use std::error;
|
||||
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::error::{JsonPayloadError, QueryPayloadError};
|
||||
use actix_web::http::StatusCode;
|
||||
@ -66,7 +67,7 @@ impl Serialize for ResponseError {
|
||||
|
||||
impl aweb::error::ResponseError for ResponseError {
|
||||
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 {
|
||||
@ -260,8 +261,8 @@ impl From<std::io::Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<actix_http::Error> for Error {
|
||||
fn from(err: actix_http::Error) -> Error {
|
||||
impl From<HttpError> for Error {
|
||||
fn from(err: HttpError) -> Error {
|
||||
Error::Internal(err.to_string())
|
||||
}
|
||||
}
|
||||
|
@ -3,27 +3,26 @@ use std::pin::Pin;
|
||||
use std::rc::Rc;
|
||||
use std::task::{Context, Poll};
|
||||
|
||||
use actix_service::{Service, Transform};
|
||||
use actix_web::{dev::ServiceRequest, dev::ServiceResponse, web};
|
||||
use actix_web::dev::{Transform, Service, ServiceResponse, ServiceRequest};
|
||||
use actix_web::web;
|
||||
use futures::future::{err, ok, Future, Ready};
|
||||
|
||||
use crate::error::{Error, ResponseError};
|
||||
use crate::Data;
|
||||
|
||||
#[derive(Clone)]
|
||||
#[derive(Clone, Copy)]
|
||||
pub enum Authentication {
|
||||
Public,
|
||||
Private,
|
||||
Admin,
|
||||
}
|
||||
|
||||
impl<S: 'static, B> Transform<S> for Authentication
|
||||
impl<S: 'static, B> Transform<S, ServiceRequest> for Authentication
|
||||
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,
|
||||
B: 'static,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<B>;
|
||||
type Error = actix_web::Error;
|
||||
type InitError = ();
|
||||
@ -32,7 +31,7 @@ where
|
||||
|
||||
fn new_transform(&self, service: S) -> Self::Future {
|
||||
ok(LoggingMiddleware {
|
||||
acl: self.clone(),
|
||||
acl: *self,
|
||||
service: Rc::new(RefCell::new(service)),
|
||||
})
|
||||
}
|
||||
@ -44,23 +43,22 @@ pub struct LoggingMiddleware<S> {
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
impl<S, B> Service for LoggingMiddleware<S>
|
||||
impl<S, B> Service<ServiceRequest> for LoggingMiddleware<S>
|
||||
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,
|
||||
B: 'static,
|
||||
{
|
||||
type Request = ServiceRequest;
|
||||
type Response = ServiceResponse<B>;
|
||||
type Error = actix_web::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)
|
||||
}
|
||||
|
||||
fn call(&mut self, req: ServiceRequest) -> Self::Future {
|
||||
let mut svc = self.service.clone();
|
||||
fn call(&self, req: ServiceRequest) -> Self::Future {
|
||||
let svc = self.service.clone();
|
||||
// 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`.
|
||||
let data = req.app_data::<web::Data<Data>>().unwrap();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/// 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_web::{
|
||||
dev::ServiceRequest,
|
||||
|
@ -1,8 +1,7 @@
|
||||
mod local_index_controller;
|
||||
pub mod actor_index_controller;
|
||||
//mod local_index_controller;
|
||||
mod updates;
|
||||
|
||||
pub use local_index_controller::LocalIndexController;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::num::NonZeroUsize;
|
||||
use std::sync::Arc;
|
||||
@ -13,6 +12,7 @@ use milli::Index;
|
||||
use milli::update::{IndexDocumentsMethod, UpdateFormat, DocumentAdditionResult};
|
||||
use serde::{Serialize, Deserialize, de::Deserializer};
|
||||
use uuid::Uuid;
|
||||
use actix_web::web::Payload;
|
||||
|
||||
pub use updates::{Processed, Processing, Failed};
|
||||
|
||||
@ -21,7 +21,6 @@ pub type UpdateStatus = updates::UpdateStatus<UpdateMeta, UpdateResult, String>;
|
||||
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct IndexMetadata {
|
||||
pub uid: String,
|
||||
uuid: Uuid,
|
||||
created_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
|
||||
/// indices, and abstract the scheduling of the updates. The implementer must be able to provide an
|
||||
/// instance of `IndexStore`
|
||||
#[async_trait::async_trait]
|
||||
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
|
||||
/// created when the addition is applied to the index.
|
||||
fn add_documents<S: AsRef<str>>(
|
||||
async fn add_documents(
|
||||
&self,
|
||||
index: S,
|
||||
index: String,
|
||||
method: IndexDocumentsMethod,
|
||||
format: UpdateFormat,
|
||||
data: &[u8],
|
||||
data: Payload,
|
||||
primary_key: Option<String>,
|
||||
) -> anyhow::Result<UpdateStatus>;
|
||||
|
||||
/// 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`.
|
||||
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
|
||||
/// 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`.
|
||||
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.
|
||||
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.
|
||||
fn swap_indices<S1: AsRef<str>, S2: AsRef<str>>(&self, index1_uid: S1, index2_uid: S2) -> 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!()
|
||||
}
|
||||
fn swap_indices(&self, index1_uid: String, index2_uid: String) -> Result<()>;
|
||||
|
||||
/// 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
|
||||
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
|
||||
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
|
||||
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>;
|
||||
}
|
||||
|
||||
|
||||
|
52
src/lib.rs
52
src/lib.rs
@ -1,4 +1,7 @@
|
||||
#![allow(clippy::or_fun_call)]
|
||||
#![allow(unused_must_use)]
|
||||
#![allow(unused_variables)]
|
||||
#![allow(dead_code)]
|
||||
|
||||
pub mod data;
|
||||
pub mod error;
|
||||
@ -7,54 +10,5 @@ pub mod option;
|
||||
pub mod routes;
|
||||
mod index_controller;
|
||||
|
||||
use actix_http::Error;
|
||||
use actix_service::ServiceFactory;
|
||||
use actix_web::{dev, web, App};
|
||||
|
||||
pub use option::Opt;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
55
src/main.rs
55
src/main.rs
@ -1,11 +1,13 @@
|
||||
use std::env;
|
||||
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{middleware, HttpServer};
|
||||
use actix_web::{middleware, HttpServer, web, web::ServiceConfig};
|
||||
use main_error::MainError;
|
||||
use meilisearch_http::helpers::NormalizePath;
|
||||
use meilisearch_http::{create_app, Data, Opt};
|
||||
use meilisearch::{Data, Opt};
|
||||
use structopt::StructOpt;
|
||||
use actix_web::App;
|
||||
use meilisearch::error::payload_error_handler;
|
||||
use actix_web::middleware::TrailingSlash;
|
||||
|
||||
//mod analytics;
|
||||
|
||||
@ -74,9 +76,34 @@ async fn main() -> Result<(), MainError> {
|
||||
print_launch_resume(&opt, &data);
|
||||
|
||||
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 || {
|
||||
create_app(&data, enable_frontend)
|
||||
.wrap(
|
||||
let app = App::new()
|
||||
.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()
|
||||
.send_wildcard()
|
||||
.allowed_headers(vec!["content-type", "x-meili-api-key"])
|
||||
@ -84,7 +111,7 @@ async fn main() -> Result<(), MainError> {
|
||||
)
|
||||
.wrap(middleware::Logger::default())
|
||||
.wrap(middleware::Compress::default())
|
||||
.wrap(NormalizePath)
|
||||
.wrap(middleware::NormalizePath::new(TrailingSlash::Trim))
|
||||
});
|
||||
|
||||
if let Some(config) = opt.get_ssl_config()? {
|
||||
@ -95,10 +122,24 @@ async fn main() -> Result<(), MainError> {
|
||||
} else {
|
||||
http_server.bind(opt.http_addr)?.run().await?;
|
||||
}
|
||||
|
||||
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) {
|
||||
let ascii_name = r#"
|
||||
888b d888 d8b 888 d8b .d8888b. 888
|
||||
|
@ -3,7 +3,7 @@ use actix_web::{delete, get, post, put};
|
||||
use actix_web::{web, HttpResponse};
|
||||
use indexmap::IndexMap;
|
||||
use log::error;
|
||||
use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
||||
//use milli::update::{IndexDocumentsMethod, UpdateFormat};
|
||||
use serde::Deserialize;
|
||||
use serde_json::Value;
|
||||
|
||||
@ -142,25 +142,26 @@ async fn add_documents_json(
|
||||
params: web::Query<UpdateDocumentsQuery>,
|
||||
body: Payload,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
let addition_result = data
|
||||
.add_documents(
|
||||
path.into_inner().index_uid,
|
||||
IndexDocumentsMethod::ReplaceDocuments,
|
||||
UpdateFormat::Json,
|
||||
body,
|
||||
params.primary_key.clone(),
|
||||
).await;
|
||||
todo!()
|
||||
//let addition_result = data
|
||||
//.add_documents(
|
||||
//path.into_inner().index_uid,
|
||||
//IndexDocumentsMethod::ReplaceDocuments,
|
||||
//UpdateFormat::Json,
|
||||
//body,
|
||||
//params.primary_key.clone(),
|
||||
//).await;
|
||||
|
||||
match addition_result {
|
||||
Ok(update) => {
|
||||
let value = serde_json::to_string(&update).unwrap();
|
||||
let response = HttpResponse::Ok().body(value);
|
||||
Ok(response)
|
||||
}
|
||||
Err(e) => {
|
||||
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
}
|
||||
}
|
||||
//match addition_result {
|
||||
//Ok(update) => {
|
||||
//let value = serde_json::to_string(&update).unwrap();
|
||||
//let response = HttpResponse::Ok().body(value);
|
||||
//Ok(response)
|
||||
//}
|
||||
//Err(e) => {
|
||||
//Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
@ -199,25 +200,26 @@ async fn update_documents(
|
||||
params: web::Query<UpdateDocumentsQuery>,
|
||||
body: web::Payload,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
let addition_result = data
|
||||
.add_documents(
|
||||
path.into_inner().index_uid,
|
||||
IndexDocumentsMethod::UpdateDocuments,
|
||||
UpdateFormat::Json,
|
||||
body,
|
||||
params.primary_key.clone(),
|
||||
).await;
|
||||
todo!()
|
||||
//let addition_result = data
|
||||
//.add_documents(
|
||||
//path.into_inner().index_uid,
|
||||
//IndexDocumentsMethod::UpdateDocuments,
|
||||
//UpdateFormat::Json,
|
||||
//body,
|
||||
//params.primary_key.clone(),
|
||||
//).await;
|
||||
|
||||
match addition_result {
|
||||
Ok(update) => {
|
||||
let value = serde_json::to_string(&update).unwrap();
|
||||
let response = HttpResponse::Ok().body(value);
|
||||
Ok(response)
|
||||
}
|
||||
Err(e) => {
|
||||
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
}
|
||||
}
|
||||
//match addition_result {
|
||||
//Ok(update) => {
|
||||
//let value = serde_json::to_string(&update).unwrap();
|
||||
//let response = HttpResponse::Ok().body(value);
|
||||
//Ok(response)
|
||||
//}
|
||||
//Err(e) => {
|
||||
//Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
||||
#[post(
|
||||
@ -229,20 +231,21 @@ async fn delete_documents(
|
||||
path: web::Path<IndexParam>,
|
||||
body: web::Json<Vec<Value>>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
let ids = body
|
||||
.iter()
|
||||
.map(|v| v.as_str().map(String::from).unwrap_or_else(|| v.to_string()))
|
||||
.collect();
|
||||
todo!()
|
||||
//let ids = body
|
||||
//.iter()
|
||||
//.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 {
|
||||
Ok(result) => {
|
||||
let json = serde_json::to_string(&result).unwrap();
|
||||
Ok(HttpResponse::Ok().body(json))
|
||||
}
|
||||
Err(e) => {
|
||||
Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
}
|
||||
}
|
||||
//match data.delete_documents(path.index_uid.clone(), ids).await {
|
||||
//Ok(result) => {
|
||||
//let json = serde_json::to_string(&result).unwrap();
|
||||
//Ok(HttpResponse::Ok().body(json))
|
||||
//}
|
||||
//Err(e) => {
|
||||
//Ok(HttpResponse::BadRequest().body(serde_json::json!({ "error": e.to_string() })))
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
||||
#[delete("/indexes/{index_uid}/documents", wrap = "Authentication::Private")]
|
||||
@ -250,13 +253,14 @@ async fn clear_all_documents(
|
||||
data: web::Data<Data>,
|
||||
path: web::Path<IndexParam>,
|
||||
) -> Result<HttpResponse, ResponseError> {
|
||||
match data.clear_documents(path.index_uid.clone()).await {
|
||||
Ok(update) => {
|
||||
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() })))
|
||||
}
|
||||
}
|
||||
todo!()
|
||||
//match data.clear_documents(path.index_uid.clone()).await {
|
||||
//Ok(update) => {
|
||||
//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() })))
|
||||
//}
|
||||
//}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ async fn create_index(
|
||||
data: web::Data<Data>,
|
||||
body: web::Json<IndexCreateRequest>,
|
||||
) -> 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) => {
|
||||
let json = serde_json::to_string(&meta).unwrap();
|
||||
Ok(HttpResponse::Ok().body(json))
|
||||
|
@ -19,7 +19,7 @@ struct KeysResponse {
|
||||
#[get("/keys", wrap = "Authentication::Admin")]
|
||||
async fn list(data: web::Data<Data>) -> HttpResponse {
|
||||
let api_keys = data.api_keys.clone();
|
||||
HttpResponse::Ok().json(KeysResponse {
|
||||
HttpResponse::Ok().json(&KeysResponse {
|
||||
private: api_keys.private,
|
||||
public: api_keys.public,
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user