From 45c1aa471ae269861970feee4b1363e27f1a3409 Mon Sep 17 00:00:00 2001 From: Alex Wellnitz Date: Wed, 14 Feb 2024 08:18:15 +0100 Subject: [PATCH] feat: add simple_on_shutdown crate and update dependencies --- Cargo.lock | 7 +++++++ Cargo.toml | 3 ++- README.md | 7 ++++++- src/main.rs | 6 ++---- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index efec9f6..9496368 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -899,6 +899,7 @@ dependencies = [ "env_logger", "log", "serde", + "simple_on_shutdown", ] [[package]] @@ -982,6 +983,12 @@ dependencies = [ "libc", ] +[[package]] +name = "simple_on_shutdown" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08df66e765f42432e83ef29ba9f45c5d80bfda7d5139baee77954829040ac6e2" + [[package]] name = "slab" version = "0.4.9" diff --git a/Cargo.toml b/Cargo.toml index 688ce73..e7073c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,4 +12,5 @@ license = "MIT" actix-web = "4" env_logger = "0.10.0" log = "0.4.19" -serde = { version = "1.0", features = ["derive"] } \ No newline at end of file +serde = { version = "1.0", features = ["derive"] } +simple_on_shutdown = "1.0.0" diff --git a/README.md b/README.md index b01a8d3..079b35a 100644 --- a/README.md +++ b/README.md @@ -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 learning exercise and is not intended for production use. +## Todo + +- [] Store index to Disk +- [] Save multiple indecies + ### Features - Indexing documents: The search engine maintains an index of documents, where each document is associated with a unique identifier. @@ -34,4 +39,4 @@ Contributions are welcome. Please submit a pull request. ### License -This project is licensed under the MIT License. \ No newline at end of file +This project is licensed under the MIT License. diff --git a/src/main.rs b/src/main.rs index b5625b9..bcbc07b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -24,12 +24,10 @@ async fn main() -> std::io::Result<()> { App::new() // Inject the search engine into the application state .app_data(app_state.clone()) - // enable logger .wrap(Logger::default()) - + // Hello Routes .service(hello::say_hello) - // Search Routes .route( "/search/index/document", @@ -42,7 +40,7 @@ async fn main() -> std::io::Result<()> { .route("/search", web::get().to(search::search)) .route("/search/debug", web::get().to(search::debug_index)) }) - .bind(("127.0.0.1", 8080))? + .bind(("127.0.0.1", 4000))? .run() .await }