Rename pending into enqueued

This commit is contained in:
Clémentine Urquizar 2021-04-07 19:46:36 +02:00
parent 0344cf5874
commit cb23775d18
No known key found for this signature in database
GPG Key ID: D8E7CC7422E77E1A
3 changed files with 14 additions and 14 deletions

View File

@ -145,7 +145,7 @@ where
// The payload is valid, we can register it to the update store. // The payload is valid, we can register it to the update store.
update_store update_store
.register_update(meta, path, uuid) .register_update(meta, path, uuid)
.map(UpdateStatus::Pending) .map(UpdateStatus::Enqueued)
.map_err(|e| UpdateError::Error(Box::new(e))) .map_err(|e| UpdateError::Error(Box::new(e)))
}) })
.await .await

View File

@ -17,7 +17,7 @@ type BEU64 = heed::zerocopy::U64<heed::byteorder::BE>;
#[derive(Clone)] #[derive(Clone)]
pub struct UpdateStore<M, N, E> { pub struct UpdateStore<M, N, E> {
pub env: Env, pub env: Env,
pending_meta: Database<OwnedType<BEU64>, SerdeJson<Pending<M>>>, pending_meta: Database<OwnedType<BEU64>, SerdeJson<Enqueued<M>>>,
pending: Database<OwnedType<BEU64>, SerdeJson<PathBuf>>, pending: Database<OwnedType<BEU64>, SerdeJson<PathBuf>>,
processed_meta: Database<OwnedType<BEU64>, SerdeJson<Processed<M, N>>>, processed_meta: Database<OwnedType<BEU64>, SerdeJson<Processed<M, N>>>,
failed_meta: Database<OwnedType<BEU64>, SerdeJson<Failed<M, E>>>, failed_meta: Database<OwnedType<BEU64>, SerdeJson<Failed<M, E>>>,
@ -167,7 +167,7 @@ where
meta: M, meta: M,
content: impl AsRef<Path>, content: impl AsRef<Path>,
index_uuid: Uuid, index_uuid: Uuid,
) -> heed::Result<Pending<M>> { ) -> heed::Result<Enqueued<M>> {
let mut wtxn = self.env.write_txn()?; let mut wtxn = self.env.write_txn()?;
// We ask the update store to give us a new update id, this is safe, // 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_id = self.new_update_id(&wtxn)?;
let update_key = BEU64::new(update_id); 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_meta.put(&mut wtxn, &update_key, &meta)?;
self.pending self.pending
.put(&mut wtxn, &update_key, &content.as_ref().to_owned())?; .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)? { 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)? { if let Some(meta) = self.processed_meta.get(&rtxn, &key)? {

View File

@ -4,14 +4,14 @@ use uuid::Uuid;
#[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Clone)] #[derive(Debug, PartialEq, Eq, Hash, Serialize, Deserialize, Clone)]
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Pending<M> { pub struct Enqueued<M> {
pub update_id: u64, pub update_id: u64,
pub meta: M, pub meta: M,
pub enqueued_at: DateTime<Utc>, pub enqueued_at: DateTime<Utc>,
pub index_uuid: Uuid, pub index_uuid: Uuid,
} }
impl<M> Pending<M> { impl<M> Enqueued<M> {
pub fn new(meta: M, update_id: u64, index_uuid: Uuid) -> Self { pub fn new(meta: M, update_id: u64, index_uuid: Uuid) -> Self {
Self { Self {
enqueued_at: Utc::now(), enqueued_at: Utc::now(),
@ -63,7 +63,7 @@ impl<M, N> Processed<M, N> {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Processing<M> { pub struct Processing<M> {
#[serde(flatten)] #[serde(flatten)]
pub from: Pending<M>, pub from: Enqueued<M>,
pub started_processing_at: DateTime<Utc>, pub started_processing_at: DateTime<Utc>,
} }
@ -101,7 +101,7 @@ impl<M> Processing<M> {
#[serde(rename_all = "camelCase")] #[serde(rename_all = "camelCase")]
pub struct Aborted<M> { pub struct Aborted<M> {
#[serde(flatten)] #[serde(flatten)]
from: Pending<M>, from: Enqueued<M>,
aborted_at: DateTime<Utc>, aborted_at: DateTime<Utc>,
} }
@ -130,7 +130,7 @@ impl<M, E> Failed<M, E> {
#[serde(tag = "status", rename_all = "camelCase")] #[serde(tag = "status", rename_all = "camelCase")]
pub enum UpdateStatus<M, N, E> { pub enum UpdateStatus<M, N, E> {
Processing(Processing<M>), Processing(Processing<M>),
Pending(Pending<M>), Enqueued(Enqueued<M>),
Processed(Processed<M, N>), Processed(Processed<M, N>),
Aborted(Aborted<M>), Aborted(Aborted<M>),
Failed(Failed<M, E>), Failed(Failed<M, E>),
@ -140,7 +140,7 @@ impl<M, N, E> UpdateStatus<M, N, E> {
pub fn id(&self) -> u64 { pub fn id(&self) -> u64 {
match self { match self {
UpdateStatus::Processing(u) => u.id(), UpdateStatus::Processing(u) => u.id(),
UpdateStatus::Pending(u) => u.id(), UpdateStatus::Enqueued(u) => u.id(),
UpdateStatus::Processed(u) => u.id(), UpdateStatus::Processed(u) => u.id(),
UpdateStatus::Aborted(u) => u.id(), UpdateStatus::Aborted(u) => u.id(),
UpdateStatus::Failed(u) => u.id(), UpdateStatus::Failed(u) => u.id(),
@ -155,9 +155,9 @@ impl<M, N, E> UpdateStatus<M, N, E> {
} }
} }
impl<M, N, E> From<Pending<M>> for UpdateStatus<M, N, E> { impl<M, N, E> From<Enqueued<M>> for UpdateStatus<M, N, E> {
fn from(other: Pending<M>) -> Self { fn from(other: Enqueued<M>) -> Self {
Self::Pending(other) Self::Enqueued(other)
} }
} }