Spaces:
Runtime error
Runtime error
neon_arch
commited on
Commit
•
c39d9ff
1
Parent(s):
686e26a
♻️ refactor: rewrite the parsing of the upstream search engines option (#302)
Browse files- src/config/parser.rs +2 -7
src/config/parser.rs
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
|
4 |
use crate::handler::paths::{file_path, FileType};
|
5 |
|
6 |
-
use crate::models::engine_models::{EngineError, EngineHandler};
|
7 |
use crate::models::parser_models::{AggregatorConfig, RateLimiter, Style};
|
8 |
use log::LevelFilter;
|
9 |
use mlua::Lua;
|
@@ -29,7 +28,7 @@ pub struct Config {
|
|
29 |
/// It stores the option to whether enable or disable debug mode.
|
30 |
pub debug: bool,
|
31 |
/// It stores all the engine names that were enabled by the user.
|
32 |
-
pub upstream_search_engines:
|
33 |
/// It stores the time (secs) which controls the server request timeout.
|
34 |
pub request_timeout: u8,
|
35 |
/// It stores the number of threads which controls the app will use to run.
|
@@ -109,11 +108,7 @@ impl Config {
|
|
109 |
logging,
|
110 |
debug,
|
111 |
upstream_search_engines: globals
|
112 |
-
.get::<_, HashMap<String, bool>>("upstream_search_engines")
|
113 |
-
.into_iter()
|
114 |
-
.filter_map(|(key, value)| value.then_some(key))
|
115 |
-
.map(|engine| EngineHandler::new(&engine))
|
116 |
-
.collect::<Result<Vec<EngineHandler>, error_stack::Report<EngineError>>>()?,
|
117 |
request_timeout: globals.get::<_, u8>("request_timeout")?,
|
118 |
threads,
|
119 |
rate_limiter: RateLimiter {
|
|
|
3 |
|
4 |
use crate::handler::paths::{file_path, FileType};
|
5 |
|
|
|
6 |
use crate::models::parser_models::{AggregatorConfig, RateLimiter, Style};
|
7 |
use log::LevelFilter;
|
8 |
use mlua::Lua;
|
|
|
28 |
/// It stores the option to whether enable or disable debug mode.
|
29 |
pub debug: bool,
|
30 |
/// It stores all the engine names that were enabled by the user.
|
31 |
+
pub upstream_search_engines: HashMap<String, bool>,
|
32 |
/// It stores the time (secs) which controls the server request timeout.
|
33 |
pub request_timeout: u8,
|
34 |
/// It stores the number of threads which controls the app will use to run.
|
|
|
108 |
logging,
|
109 |
debug,
|
110 |
upstream_search_engines: globals
|
111 |
+
.get::<_, HashMap<String, bool>>("upstream_search_engines")?,
|
|
|
|
|
|
|
|
|
112 |
request_timeout: globals.get::<_, u8>("request_timeout")?,
|
113 |
threads,
|
114 |
rate_limiter: RateLimiter {
|