use serde::{Deserialize, Serialize};
use serde_json::Value as JsonValue;
use crate::{
Result,
store::{DbCollectionIden, StoreIden},
};
use super::message::DeliveryStatus;
#[derive(Default, Deserialize, Serialize, Debug, Clone)]
pub struct Delivery {
pub id: String,
pub msg_id: String,
pub pid: String,
pub tid: String,
pub chan_id: String,
pub chan_pattern: String,
pub status: DeliveryStatus,
pub retry_times: i32,
pub create_time: i64,
pub update_time: i64,
pub timestamp: i64,
pub v: i32,
}
impl DbCollectionIden for Delivery {
fn iden() -> StoreIden {
StoreIden::Deliveries
}
fn indexed_fields() -> &'static [&'static str] {
&["pid", "tid", "status", "msg_id", "chan_id", "update_time"]
}
fn ordered_index_fields() -> &'static [&'static str] {
&["update_time"]
}
fn version() -> i32 {
1
}
fn upcast(value: JsonValue) -> Result<Self> {
Self::upcast_current(value)
}
}