feat: add simple_on_shutdown crate and update dependencies

This commit is contained in:
Alex Wellnitz 2024-02-14 08:18:15 +01:00
parent 42050c3315
commit 45c1aa471a
4 changed files with 17 additions and 6 deletions

7
Cargo.lock generated
View File

@ -899,6 +899,7 @@ dependencies = [
"env_logger", "env_logger",
"log", "log",
"serde", "serde",
"simple_on_shutdown",
] ]
[[package]] [[package]]
@ -982,6 +983,12 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "simple_on_shutdown"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08df66e765f42432e83ef29ba9f45c5d80bfda7d5139baee77954829040ac6e2"
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.9" version = "0.4.9"

View File

@ -13,3 +13,4 @@ actix-web = "4"
env_logger = "0.10.0" env_logger = "0.10.0"
log = "0.4.19" log = "0.4.19"
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
simple_on_shutdown = "1.0.0"

View File

@ -6,6 +6,11 @@
This project is a simple implementation of a search engine in Rust. It uses the BM25 algorithm for ranking documents. This project is a simple implementation of a search engine in Rust. It uses the BM25 algorithm for ranking documents.
This project is a learning exercise and is not intended for production use. This project is a learning exercise and is not intended for production use.
## Todo
- [] Store index to Disk
- [] Save multiple indecies
### Features ### Features
- Indexing documents: The search engine maintains an index of documents, where each document is associated with a unique identifier. - Indexing documents: The search engine maintains an index of documents, where each document is associated with a unique identifier.

View File

@ -24,12 +24,10 @@ async fn main() -> std::io::Result<()> {
App::new() App::new()
// Inject the search engine into the application state // Inject the search engine into the application state
.app_data(app_state.clone()) .app_data(app_state.clone())
// enable logger // enable logger
.wrap(Logger::default()) .wrap(Logger::default())
// Hello Routes
.service(hello::say_hello) .service(hello::say_hello)
// Search Routes // Search Routes
.route( .route(
"/search/index/document", "/search/index/document",
@ -42,7 +40,7 @@ async fn main() -> std::io::Result<()> {
.route("/search", web::get().to(search::search)) .route("/search", web::get().to(search::search))
.route("/search/debug", web::get().to(search::debug_index)) .route("/search/debug", web::get().to(search::debug_index))
}) })
.bind(("127.0.0.1", 8080))? .bind(("127.0.0.1", 4000))?
.run() .run()
.await .await
} }