aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSangTran-127 <tranquangsang12.7@gmail.com>2026-08-08 11:31:29 +0700
committerSangTran-127 <tranquangsang12.7@gmail.com>2026-08-08 11:31:29 +0700
commit77a3b3e86b06504bdf37e35d83a192806a95a63e (patch)
treed37f9f6cfe04064823803f28e2b0cc4a00e3127c
parent967c0348c4f5c44801da90dbd9cdaeca09560a81 (diff)
downloadgoflink-77a3b3e86b06504bdf37e35d83a192806a95a63e.tar.gz
goflink-77a3b3e86b06504bdf37e35d83a192806a95a63e.zip
initialize goflink module with core stream record implementation
-rw-r--r--.gitignore1
-rw-r--r--core/record.go40
-rw-r--r--go.mod3
-rw-r--r--main.go13
4 files changed, 57 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..62c8935
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+.idea/ \ No newline at end of file
diff --git a/core/record.go b/core/record.go
new file mode 100644
index 0000000..cb160b2
--- /dev/null
+++ b/core/record.go
@@ -0,0 +1,40 @@
+package core
+
+type RecordType byte
+
+const (
+ RecordData RecordType = iota
+ RecordWatermark
+ RecordBarrier
+)
+
+type StreamRecord[T any] struct {
+ Value T
+ Key string // for keyBy stateful processing
+ Timestamp int64 // epoch ms time
+ BarrierID uint64 // ID checkpoint barrier
+ Type RecordType
+}
+
+func NewDataRecord[T any](key string, val T, timestamp int64) *StreamRecord[T] {
+ return &StreamRecord[T]{
+ Value: val,
+ Key: key,
+ Timestamp: timestamp,
+ Type: RecordData,
+ }
+}
+
+func NewWatermarkRecord[T any](timestamp int64) *StreamRecord[T] {
+ return &StreamRecord[T]{
+ Type: RecordWatermark,
+ Timestamp: timestamp,
+ }
+}
+
+func NewBarrierRecord[T any](barrierID uint64) *StreamRecord[T] {
+ return &StreamRecord[T]{
+ Type: RecordBarrier,
+ BarrierID: barrierID,
+ }
+}
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..5d934cd
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module goflink
+
+go 1.26.3
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..25792c1
--- /dev/null
+++ b/main.go
@@ -0,0 +1,13 @@
+package main
+
+import (
+ "fmt"
+ "goflink/core"
+ "unsafe"
+)
+
+func main() {
+
+ fmt.Printf("GoodRecord Size: %d bytes\n", unsafe.Sizeof(core.StreamRecord[int]{}))
+
+}