From 8030a822ab59ed253a3fa99353b491eb545f928b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renault?= Date: Wed, 28 Aug 2019 13:42:20 +0200 Subject: [PATCH] test: Add a way to setup the fetch timeout of the query-database example --- meilidb/examples/query-database.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/meilidb/examples/query-database.rs b/meilidb/examples/query-database.rs index 58f91c383..d939c0b70 100644 --- a/meilidb/examples/query-database.rs +++ b/meilidb/examples/query-database.rs @@ -24,6 +24,9 @@ pub struct Opt { #[structopt(parse(from_os_str))] pub database_path: PathBuf, + #[structopt(long = "fetch-timeout-ms")] + pub fetch_timeout_ms: Option, + /// Fields that must be displayed. pub displayed_fields: Vec, @@ -159,7 +162,13 @@ fn main() -> Result<(), Box> { Ok(query) => { let start_total = Instant::now(); - let builder = index.query_builder().with_fetch_timeout(Duration::from_millis(40)); + let builder = match opt.fetch_timeout_ms { + Some(timeout_ms) => { + let timeout = Duration::from_millis(timeout_ms); + index.query_builder().with_fetch_timeout(timeout) + }, + None => index.query_builder(), + }; let documents = builder.query(&query, 0..opt.number_results)?; let mut retrieve_duration = Duration::default();