pub struct CdcEnvelope<T> {
pub op: String,
pub ts_ms: i64,
pub source: CdcSource,
pub before: Option<T>,
pub after: Option<T>,
}Expand description
CDC envelope for sink serialization.
Compatible with Debezium envelope format for interoperability with downstream systems (Kafka Connect, data lakes, etc.).
§Debezium Operation Codes
"c": Create (insert)"u": Update"d": Delete"r": Read (snapshot)
§Example
use laminar_core::operator::changelog::{CdcEnvelope, CdcSource};
use serde_json::json;
let source = CdcSource::new("laminardb", "default", "orders");
// Insert
let insert = CdcEnvelope::insert(json!({"id": 1, "amount": 100}), source.clone(), 1000);
assert_eq!(insert.op, "c");
// Delete
let delete = CdcEnvelope::delete(json!({"id": 1}), source.clone(), 2000);
assert_eq!(delete.op, "d");
// Update
let update = CdcEnvelope::update(
json!({"id": 1, "amount": 100}),
json!({"id": 1, "amount": 150}),
source,
3000,
);
assert_eq!(update.op, "u");Fields§
§op: StringOperation type: “c” (create), “u” (update), “d” (delete), “r” (read/snapshot)
ts_ms: i64Timestamp in milliseconds since epoch
source: CdcSourceSource metadata
before: Option<T>Value before change (for updates/deletes)
after: Option<T>Value after change (for inserts/updates)
Implementations§
Source§impl<T> CdcEnvelope<T>
impl<T> CdcEnvelope<T>
Sourcepub fn insert(after: T, source: CdcSource, ts_ms: i64) -> Self
pub fn insert(after: T, source: CdcSource, ts_ms: i64) -> Self
Creates an insert (create) envelope.
Sourcepub fn update(before: T, after: T, source: CdcSource, ts_ms: i64) -> Self
pub fn update(before: T, after: T, source: CdcSource, ts_ms: i64) -> Self
Creates an update envelope.
Trait Implementations§
Source§impl<T: Clone> Clone for CdcEnvelope<T>
impl<T: Clone> Clone for CdcEnvelope<T>
Source§fn clone(&self) -> CdcEnvelope<T>
fn clone(&self) -> CdcEnvelope<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for CdcEnvelope<T>
impl<T: Debug> Debug for CdcEnvelope<T>
Source§impl<'de, T> Deserialize<'de> for CdcEnvelope<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for CdcEnvelope<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl<T> Freeze for CdcEnvelope<T>where
T: Freeze,
impl<T> RefUnwindSafe for CdcEnvelope<T>where
T: RefUnwindSafe,
impl<T> Send for CdcEnvelope<T>where
T: Send,
impl<T> Sync for CdcEnvelope<T>where
T: Sync,
impl<T> Unpin for CdcEnvelope<T>where
T: Unpin,
impl<T> UnsafeUnpin for CdcEnvelope<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for CdcEnvelope<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Code for Twhere
T: Serialize + DeserializeOwned,
impl<T> Code for Twhere
T: Serialize + DeserializeOwned,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Returns the layout of the type.