Skip to main content

krabka_client_streams/processor/
record.rs

1//! `Record<K,V>` and `RecordContext`, which flow through the processor graph.
2
3/// A key/value record with a timestamp.
4///
5/// `key` is optional, because a Kafka record can have a null key. `value` is
6/// typed and always present at this layer. The DSL represents a table deletion
7/// as a change record 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 that the processor handles now. This is the
27/// JVM `RecordContext`.
28///
29/// [`ProcessorContext::record_context`](crate::processor::ProcessorContext::record_context)
30/// exposes it.
31#[derive(Debug, Clone, PartialEq, Eq)]
32pub struct RecordContext {
33    pub topic: String,
34    pub partition: i32,
35    pub offset: i64,
36    pub timestamp: i64,
37}