From cb23775d180c69f18a91619ffc8bf4cc6406f85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9mentine=20Urquizar?= Date: Wed, 7 Apr 2021 19:46:36 +0200 Subject: [PATCH] Rename pending into enqueued --- .../src/index_controller/update_actor/actor.rs | 2 +- .../update_actor/update_store.rs | 8 ++++---- .../src/index_controller/updates.rs | 18 +++++++++--------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/meilisearch-http/src/index_controller/update_actor/actor.rs b/meilisearch-http/src/index_controller/update_actor/actor.rs index 688472740..d87b910d6 100644 --- a/meilisearch-http/src/index_controller/update_actor/actor.rs +++ b/meilisearch-http/src/index_controller/update_actor/actor.rs @@ -145,7 +145,7 @@ where // The payload is valid, we can register it to the update store. update_store .register_update(meta, path, uuid) - .map(UpdateStatus::Pending) + .map(UpdateStatus::Enqueued) .map_err(|e| UpdateError::Error(Box::new(e))) }) .await diff --git a/meilisearch-http/src/index_controller/update_actor/update_store.rs b/meilisearch-http/src/index_controller/update_actor/update_store.rs index f8dcace7b..a083eb186 100644 --- a/meilisearch-http/src/index_controller/update_actor/update_store.rs +++ b/meilisearch-http/src/index_controller/update_actor/update_store.rs @@ -17,7 +17,7 @@ type BEU64 = heed::zerocopy::U64; #[derive(Clone)] pub struct UpdateStore { pub env: Env, - pending_meta: Database, SerdeJson>>, + pending_meta: Database, SerdeJson>>, pending: Database, SerdeJson>, processed_meta: Database, SerdeJson>>, failed_meta: Database, SerdeJson>>, @@ -167,7 +167,7 @@ where meta: M, content: impl AsRef, index_uuid: Uuid, - ) -> heed::Result> { + ) -> heed::Result> { let mut wtxn = self.env.write_txn()?; // We ask the update store to give us a new update id, this is safe, @@ -177,7 +177,7 @@ where let update_id = self.new_update_id(&wtxn)?; let update_key = BEU64::new(update_id); - let meta = Pending::new(meta, update_id, index_uuid); + let meta = Enqueued::new(meta, update_id, index_uuid); self.pending_meta.put(&mut wtxn, &update_key, &meta)?; self.pending .put(&mut wtxn, &update_key, &content.as_ref().to_owned())?; @@ -303,7 +303,7 @@ where } if let Some(meta) = self.pending_meta.get(&rtxn, &key)? { - return Ok(Some(UpdateStatus::Pending(meta))); + return Ok(Some(UpdateStatus::Enqueued(meta))); } if let Some(meta) = self.processed_meta.get(&rtxn, &key)? { diff --git a/meilisearch-http/src/index_controller/updates.rs b/meilisearch-http/src/index_controller/updates.rs index 3c70aee71..42712a396 100644 --- a/meilisearch-http/src/index_controller/updates.rs +++ b/meilisearch-http/src/index_controller/updates.rs @@ -4,14 +4,14 @@ use uuid::Uuid; #[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Clone)] #[serde(rename_all = "camelCase")] -pub struct Pending { +pub struct Enqueued { pub update_id: u64, pub meta: M, pub enqueued_at: DateTime, pub index_uuid: Uuid, } -impl Pending { +impl Enqueued { pub fn new(meta: M, update_id: u64, index_uuid: Uuid) -> Self { Self { enqueued_at: Utc::now(), @@ -63,7 +63,7 @@ impl Processed { #[serde(rename_all = "camelCase")] pub struct Processing { #[serde(flatten)] - pub from: Pending, + pub from: Enqueued, pub started_processing_at: DateTime, } @@ -101,7 +101,7 @@ impl Processing { #[serde(rename_all = "camelCase")] pub struct Aborted { #[serde(flatten)] - from: Pending, + from: Enqueued, aborted_at: DateTime, } @@ -130,7 +130,7 @@ impl Failed { #[serde(tag = "status", rename_all = "camelCase")] pub enum UpdateStatus { Processing(Processing), - Pending(Pending), + Enqueued(Enqueued), Processed(Processed), Aborted(Aborted), Failed(Failed), @@ -140,7 +140,7 @@ impl UpdateStatus { pub fn id(&self) -> u64 { match self { UpdateStatus::Processing(u) => u.id(), - UpdateStatus::Pending(u) => u.id(), + UpdateStatus::Enqueued(u) => u.id(), UpdateStatus::Processed(u) => u.id(), UpdateStatus::Aborted(u) => u.id(), UpdateStatus::Failed(u) => u.id(), @@ -155,9 +155,9 @@ impl UpdateStatus { } } -impl From> for UpdateStatus { - fn from(other: Pending) -> Self { - Self::Pending(other) +impl From> for UpdateStatus { + fn from(other: Enqueued) -> Self { + Self::Enqueued(other) } }