mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-29 16:24:26 +01:00
remove a lot of unecessary clone and ref
This commit is contained in:
parent
4d25c159e6
commit
7e52f1effb
@ -130,7 +130,7 @@ impl CompatV5ToV6 {
|
|||||||
v5::Details::DocumentAddition { received_documents, indexed_documents } => {
|
v5::Details::DocumentAddition { received_documents, indexed_documents } => {
|
||||||
v6::Details::DocumentAdditionOrUpdate {
|
v6::Details::DocumentAdditionOrUpdate {
|
||||||
received_documents: received_documents as u64,
|
received_documents: received_documents as u64,
|
||||||
indexed_documents: indexed_documents.map(|i| i as u64),
|
indexed_documents,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
v5::Details::Settings { settings } => {
|
v5::Details::Settings { settings } => {
|
||||||
|
@ -269,16 +269,16 @@ impl IndexScheduler {
|
|||||||
must_stop_processing: self.must_stop_processing.clone(),
|
must_stop_processing: self.must_stop_processing.clone(),
|
||||||
processing_tasks: self.processing_tasks.clone(),
|
processing_tasks: self.processing_tasks.clone(),
|
||||||
file_store: self.file_store.clone(),
|
file_store: self.file_store.clone(),
|
||||||
all_tasks: self.all_tasks.clone(),
|
all_tasks: self.all_tasks,
|
||||||
status: self.status.clone(),
|
status: self.status,
|
||||||
kind: self.kind.clone(),
|
kind: self.kind,
|
||||||
index_tasks: self.index_tasks.clone(),
|
index_tasks: self.index_tasks,
|
||||||
enqueued_at: self.enqueued_at.clone(),
|
enqueued_at: self.enqueued_at,
|
||||||
started_at: self.started_at.clone(),
|
started_at: self.started_at,
|
||||||
finished_at: self.finished_at.clone(),
|
finished_at: self.finished_at,
|
||||||
index_mapper: self.index_mapper.clone(),
|
index_mapper: self.index_mapper.clone(),
|
||||||
wake_up: self.wake_up.clone(),
|
wake_up: self.wake_up.clone(),
|
||||||
autobatching_enabled: self.autobatching_enabled.clone(),
|
autobatching_enabled: self.autobatching_enabled,
|
||||||
dumps_path: self.dumps_path.clone(),
|
dumps_path: self.dumps_path.clone(),
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
test_breakpoint_sdr: self.test_breakpoint_sdr.clone(),
|
test_breakpoint_sdr: self.test_breakpoint_sdr.clone(),
|
||||||
@ -808,7 +808,7 @@ impl IndexScheduler {
|
|||||||
let res = {
|
let res = {
|
||||||
let cloned_index_scheduler = self.private_clone();
|
let cloned_index_scheduler = self.private_clone();
|
||||||
let handle = std::thread::spawn(move || cloned_index_scheduler.process_batch(batch));
|
let handle = std::thread::spawn(move || cloned_index_scheduler.process_batch(batch));
|
||||||
handle.join().unwrap_or_else(|_| Err(Error::ProcessBatchPanicked))
|
handle.join().unwrap_or(Err(Error::ProcessBatchPanicked))
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
@ -1223,7 +1223,7 @@ mod tests {
|
|||||||
index_scheduler
|
index_scheduler
|
||||||
.register(KindWithContent::TaskDeletion {
|
.register(KindWithContent::TaskDeletion {
|
||||||
query: "test_query".to_owned(),
|
query: "test_query".to_owned(),
|
||||||
tasks: RoaringBitmap::from_iter(&[0, 1]),
|
tasks: RoaringBitmap::from_iter([0, 1]),
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
index_scheduler.assert_internally_consistent();
|
index_scheduler.assert_internally_consistent();
|
||||||
@ -1279,7 +1279,7 @@ mod tests {
|
|||||||
index_scheduler
|
index_scheduler
|
||||||
.register(KindWithContent::TaskDeletion {
|
.register(KindWithContent::TaskDeletion {
|
||||||
query: "test_query".to_owned(),
|
query: "test_query".to_owned(),
|
||||||
tasks: RoaringBitmap::from_iter(&[0]),
|
tasks: RoaringBitmap::from_iter([0]),
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
index_scheduler.assert_internally_consistent();
|
index_scheduler.assert_internally_consistent();
|
||||||
@ -1322,7 +1322,7 @@ mod tests {
|
|||||||
index_scheduler
|
index_scheduler
|
||||||
.register(KindWithContent::TaskDeletion {
|
.register(KindWithContent::TaskDeletion {
|
||||||
query: "test_query".to_owned(),
|
query: "test_query".to_owned(),
|
||||||
tasks: RoaringBitmap::from_iter(&[0]),
|
tasks: RoaringBitmap::from_iter([0]),
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
index_scheduler.assert_internally_consistent();
|
index_scheduler.assert_internally_consistent();
|
||||||
|
@ -436,7 +436,7 @@ impl IndexScheduler {
|
|||||||
}
|
}
|
||||||
Details::Dump { dump_uid: d1 } => {
|
Details::Dump { dump_uid: d1 } => {
|
||||||
assert!(
|
assert!(
|
||||||
matches!(&kind, KindWithContent::DumpExport { dump_uid: d2, keys: _, instance_uid: _ } if &d1 == d2 )
|
matches!(&kind, KindWithContent::DumpCreation { dump_uid: d2, keys: _, instance_uid: _ } if &d1 == d2 )
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -96,7 +96,7 @@ async fn error_access_expired_key() {
|
|||||||
assert!(response["key"].is_string());
|
assert!(response["key"].is_string());
|
||||||
|
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
// wait until the key is expired.
|
// wait until the key is expired.
|
||||||
thread::sleep(time::Duration::new(1, 0));
|
thread::sleep(time::Duration::new(1, 0));
|
||||||
@ -126,7 +126,7 @@ async fn error_access_unauthorized_index() {
|
|||||||
assert!(response["key"].is_string());
|
assert!(response["key"].is_string());
|
||||||
|
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
for (method, route) in AUTHORIZATIONS
|
for (method, route) in AUTHORIZATIONS
|
||||||
.keys()
|
.keys()
|
||||||
@ -160,7 +160,7 @@ async fn error_access_unauthorized_action() {
|
|||||||
assert!(response["key"].is_string());
|
assert!(response["key"].is_string());
|
||||||
|
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
let (response, code) = server.dummy_request(method, route).await;
|
let (response, code) = server.dummy_request(method, route).await;
|
||||||
|
|
||||||
assert_eq!(response, INVALID_RESPONSE.clone(), "on route: {:?} - {:?}", method, route);
|
assert_eq!(response, INVALID_RESPONSE.clone(), "on route: {:?} - {:?}", method, route);
|
||||||
@ -203,7 +203,7 @@ async fn access_authorized_restricted_index() {
|
|||||||
assert!(response["key"].is_string());
|
assert!(response["key"].is_string());
|
||||||
|
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
let (response, code) = server.dummy_request(method, route).await;
|
let (response, code) = server.dummy_request(method, route).await;
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ async fn access_authorized_no_index_restriction() {
|
|||||||
assert!(response["key"].is_string());
|
assert!(response["key"].is_string());
|
||||||
|
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
let (response, code) = server.dummy_request(method, route).await;
|
let (response, code) = server.dummy_request(method, route).await;
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ async fn access_authorized_stats_restricted_index() {
|
|||||||
|
|
||||||
// use created key.
|
// use created key.
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
let (response, code) = server.stats().await;
|
let (response, code) = server.stats().await;
|
||||||
assert_eq!(200, code, "{:?}", &response);
|
assert_eq!(200, code, "{:?}", &response);
|
||||||
@ -326,7 +326,7 @@ async fn access_authorized_stats_no_index_restriction() {
|
|||||||
|
|
||||||
// use created key.
|
// use created key.
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
let (response, code) = server.stats().await;
|
let (response, code) = server.stats().await;
|
||||||
assert_eq!(200, code, "{:?}", &response);
|
assert_eq!(200, code, "{:?}", &response);
|
||||||
@ -366,7 +366,7 @@ async fn list_authorized_indexes_restricted_index() {
|
|||||||
|
|
||||||
// use created key.
|
// use created key.
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
let (response, code) = server.list_indexes(None, None).await;
|
let (response, code) = server.list_indexes(None, None).await;
|
||||||
assert_eq!(200, code, "{:?}", &response);
|
assert_eq!(200, code, "{:?}", &response);
|
||||||
@ -407,7 +407,7 @@ async fn list_authorized_indexes_no_index_restriction() {
|
|||||||
|
|
||||||
// use created key.
|
// use created key.
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
let (response, code) = server.list_indexes(None, None).await;
|
let (response, code) = server.list_indexes(None, None).await;
|
||||||
assert_eq!(200, code, "{:?}", &response);
|
assert_eq!(200, code, "{:?}", &response);
|
||||||
@ -447,7 +447,7 @@ async fn list_authorized_tasks_restricted_index() {
|
|||||||
|
|
||||||
// use created key.
|
// use created key.
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
let (response, code) = server.service.get("/tasks").await;
|
let (response, code) = server.service.get("/tasks").await;
|
||||||
assert_eq!(200, code, "{:?}", &response);
|
assert_eq!(200, code, "{:?}", &response);
|
||||||
@ -487,7 +487,7 @@ async fn list_authorized_tasks_no_index_restriction() {
|
|||||||
|
|
||||||
// use created key.
|
// use created key.
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
let (response, code) = server.service.get("/tasks").await;
|
let (response, code) = server.service.get("/tasks").await;
|
||||||
assert_eq!(200, code, "{:?}", &response);
|
assert_eq!(200, code, "{:?}", &response);
|
||||||
@ -518,7 +518,7 @@ async fn error_creating_index_without_action() {
|
|||||||
|
|
||||||
// use created key.
|
// use created key.
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
let expected_error = json!({
|
let expected_error = json!({
|
||||||
"message": "Index `test` not found.",
|
"message": "Index `test` not found.",
|
||||||
@ -598,7 +598,7 @@ async fn lazy_create_index() {
|
|||||||
|
|
||||||
// use created key.
|
// use created key.
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
// try to create a index via add documents route
|
// try to create a index via add documents route
|
||||||
let index = server.index("test");
|
let index = server.index("test");
|
||||||
@ -665,7 +665,7 @@ async fn error_creating_index_without_index() {
|
|||||||
|
|
||||||
// use created key.
|
// use created key.
|
||||||
let key = response["key"].as_str().unwrap();
|
let key = response["key"].as_str().unwrap();
|
||||||
server.use_api_key(&key);
|
server.use_api_key(key);
|
||||||
|
|
||||||
// try to create a index via add documents route
|
// try to create a index via add documents route
|
||||||
let index = server.index("test");
|
let index = server.index("test");
|
||||||
|
@ -470,7 +470,7 @@ async fn error_access_forbidden_routes() {
|
|||||||
"searchRules" => json!(["*"]),
|
"searchRules" => json!(["*"]),
|
||||||
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
|
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
|
||||||
};
|
};
|
||||||
let web_token = generate_tenant_token(&uid, &key, tenant_token);
|
let web_token = generate_tenant_token(uid, key, tenant_token);
|
||||||
server.use_api_key(&web_token);
|
server.use_api_key(&web_token);
|
||||||
|
|
||||||
for ((method, route), actions) in AUTHORIZATIONS.iter() {
|
for ((method, route), actions) in AUTHORIZATIONS.iter() {
|
||||||
@ -506,7 +506,7 @@ async fn error_access_expired_parent_key() {
|
|||||||
"searchRules" => json!(["*"]),
|
"searchRules" => json!(["*"]),
|
||||||
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
|
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
|
||||||
};
|
};
|
||||||
let web_token = generate_tenant_token(&uid, &key, tenant_token);
|
let web_token = generate_tenant_token(uid, key, tenant_token);
|
||||||
server.use_api_key(&web_token);
|
server.use_api_key(&web_token);
|
||||||
|
|
||||||
// test search request while parent_key is not expired
|
// test search request while parent_key is not expired
|
||||||
@ -545,7 +545,7 @@ async fn error_access_modified_token() {
|
|||||||
"searchRules" => json!(["products"]),
|
"searchRules" => json!(["products"]),
|
||||||
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
|
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
|
||||||
};
|
};
|
||||||
let web_token = generate_tenant_token(&uid, &key, tenant_token);
|
let web_token = generate_tenant_token(uid, key, tenant_token);
|
||||||
server.use_api_key(&web_token);
|
server.use_api_key(&web_token);
|
||||||
|
|
||||||
// test search request while web_token is valid
|
// test search request while web_token is valid
|
||||||
@ -558,7 +558,7 @@ async fn error_access_modified_token() {
|
|||||||
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
|
"exp" => json!((OffsetDateTime::now_utc() + Duration::hours(1)).unix_timestamp())
|
||||||
};
|
};
|
||||||
|
|
||||||
let alt = generate_tenant_token(&uid, &key, tenant_token);
|
let alt = generate_tenant_token(uid, key, tenant_token);
|
||||||
let altered_token = [
|
let altered_token = [
|
||||||
web_token.split('.').next().unwrap(),
|
web_token.split('.').next().unwrap(),
|
||||||
alt.split('.').nth(1).unwrap(),
|
alt.split('.').nth(1).unwrap(),
|
||||||
|
Loading…
Reference in New Issue
Block a user