Skip to main content

crabka_client_streams/processor/
record.rs

1//! `Record<K,V>` flowing through the processor graph + `RecordContext`.
2
3/// A key/value record with a timestamp.
4///
5/// `key` is optional because Kafka records may have null keys. `value` is typed
6/// and present at this layer; table deletions are represented in the DSL as
7/// change records whose `new` value is `None`.
8#[derive(Debug, Clone, PartialEq, Eq)]
9pub struct Record<K, V> {
10    pub key: Option<K>,
11    pub value: V,
12    pub timestamp: i64,
13}
14
15impl<K, V> Record<K, V> {
16    #[must_use]
17    pub fn new(key: Option<K>, value: V, timestamp: i64) -> Self {
18        Self {
19            key,
20            value,
21            timestamp,
22        }
23    }
24}
25
26/// Metadata about the source record currently being processed (JVM
27/// `RecordContext`). Exposed via
28/// [`ProcessorContext::record_context`](crate::processor::ProcessorContext::record_context).
29#[derive(Debug, Clone, PartialEq, Eq)]
30pub struct RecordContext {
31    pub topic: String,
32    pub partition: i32,
33    pub offset: i64,
34    pub timestamp: i64,
35}