2023-11-18 13:56:13 +00:00
|
|
|
use crate::sql::duration::Duration;
|
2023-08-17 18:03:46 +00:00
|
|
|
use revision::revisioned;
|
2023-06-28 07:19:40 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use std::fmt::{self, Display, Formatter};
|
|
|
|
use std::str;
|
|
|
|
use std::time;
|
|
|
|
|
2023-08-18 22:51:56 +00:00
|
|
|
#[derive(Clone, Debug, Eq, PartialEq, PartialOrd, Serialize, Deserialize, Hash)]
|
2024-02-28 19:35:39 +00:00
|
|
|
#[revisioned(revision = 2)]
|
2023-06-28 07:19:40 +00:00
|
|
|
pub struct ChangeFeed {
|
|
|
|
pub expiry: time::Duration,
|
2024-02-28 19:35:39 +00:00
|
|
|
#[revision(start = 2)]
|
|
|
|
pub store_original: bool,
|
2023-06-28 07:19:40 +00:00
|
|
|
}
|
|
|
|
impl Display for ChangeFeed {
|
|
|
|
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
|
|
|
|
write!(f, "CHANGEFEED {}", Duration(self.expiry))?;
|
2024-02-28 19:35:39 +00:00
|
|
|
if self.store_original {
|
|
|
|
write!(f, " INCLUDE ORIGINAL")?;
|
|
|
|
};
|
2023-06-28 07:19:40 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for ChangeFeed {
|
|
|
|
fn default() -> Self {
|
|
|
|
Self {
|
|
|
|
expiry: time::Duration::from_secs(0),
|
2024-02-28 19:35:39 +00:00
|
|
|
store_original: false,
|
2023-06-28 07:19:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|