Update Queue system to include item status tracking and TTL feature. Items with pending status will only be processed and will be removed once TTL duration expires
pub struct QueueItem<T> {
/// The inner value wrapped by the Queue Item.
inner: T,
/// The current state of the item in the queue.
state: QueueItemState,
/// The time when the item was enqueued.
enqueued_at: u128,
/// Time to live
ttl: u128,
}
/// The status of the item in the queue.
#[derive(Debug, Clone, PartialEq, Default, Serialize, Deserialize)]
pub enum QueueItemState {
/// The current item is pending and waiting in the queue to be dequeued and processed.
#[default]
Pending,
/// The item is being processed.
Processing {
/// A meaningful step for the current item state.
step: String,
/// A meaningful progress percentage for the current item state (0 to 1).
progress: Option<f32>,
},
/// The item failed to be processed.
Failed {
/// The error message.
reason: String,
},
/// The item was successfully processed.
Processed,
}
Summary of changes
Update Queue system to include item status tracking and TTL feature. Items with pending status will only be processed and will be removed once TTL duration expires
Reference issue to close (if applicable)
Code Checklist