diff options
Diffstat (limited to 'core/record.go')
| -rw-r--r-- | core/record.go | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/core/record.go b/core/record.go new file mode 100644 index 0000000..e18e58d --- /dev/null +++ b/core/record.go | |||
| @@ -0,0 +1,40 @@ | |||
| 1 | package core | ||
| 2 | |||
| 3 | type RecordType byte | ||
| 4 | |||
| 5 | const ( | ||
| 6 | RecordData RecordType = iota | ||
| 7 | RecordWatermark | ||
| 8 | RecordBarrier | ||
| 9 | ) | ||
| 10 | |||
| 11 | type StreamRecord[T any] struct { | ||
| 12 | Value T | ||
| 13 | Key string // for keyBy stateful processing | ||
| 14 | Timestamp int64 // epoch ms time | ||
| 15 | BarrierID uint64 // ID checkpoint barrier | ||
| 16 | Type RecordType | ||
| 17 | } | ||
| 18 | |||
| 19 | func NewDataRecord[T any](key string, val T, timestamp int64) StreamRecord[T] { | ||
| 20 | return StreamRecord[T]{ | ||
| 21 | Value: val, | ||
| 22 | Key: key, | ||
| 23 | Timestamp: timestamp, | ||
| 24 | Type: RecordData, | ||
| 25 | } | ||
| 26 | } | ||
| 27 | |||
| 28 | func NewWatermarkRecord[T any](timestamp int64) StreamRecord[T] { | ||
| 29 | return StreamRecord[T]{ | ||
| 30 | Type: RecordWatermark, | ||
| 31 | Timestamp: timestamp, | ||
| 32 | } | ||
| 33 | } | ||
| 34 | |||
| 35 | func NewBarrierRecord[T any](barrierID uint64) StreamRecord[T] { | ||
| 36 | return StreamRecord[T]{ | ||
| 37 | Type: RecordBarrier, | ||
| 38 | BarrierID: barrierID, | ||
| 39 | } | ||
| 40 | } | ||
