aboutsummaryrefslogtreecommitdiff
path: root/core/state_backend.go
diff options
context:
space:
mode:
authorSangTran-127 <tranquangsang12.7@gmail.com>2026-08-09 18:32:44 +0700
committerSangTran-127 <tranquangsang12.7@gmail.com>2026-08-09 18:32:44 +0700
commit4ca27aec303f54dc9ee670c67c2fefa80dd004a1 (patch)
tree5628714f47e374bfb98c1cea99970b19892e8b3e /core/state_backend.go
parenta892cb5b1d121177881fa56a79abbafef5880a80 (diff)
downloadgoflink-4ca27aec303f54dc9ee670c67c2fefa80dd004a1.tar.gz
goflink-4ca27aec303f54dc9ee670c67c2fefa80dd004a1.zip
feat: add KeyByOperator and wordCounter for stateful processing
Diffstat (limited to 'core/state_backend.go')
-rw-r--r--core/state_backend.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/core/state_backend.go b/core/state_backend.go
index 219bb63..f8b83fb 100644
--- a/core/state_backend.go
+++ b/core/state_backend.go
@@ -11,3 +11,16 @@ type StateBackend interface {
// GetValueState will perform in disk
GetValueState(ctx context.Context, key string) (ValueState[any], error)
}
+
+type stateBackendKeyType struct{}
+
+var stateBackendKey stateBackendKeyType
+
+func InjectStateBackend(ctx context.Context, state StateBackend) context.Context {
+ return context.WithValue(ctx, stateBackendKey, state)
+}
+
+func ExtractStateBackend(ctx context.Context) (StateBackend, bool) {
+ backend, ok := ctx.Value(stateBackendKey).(StateBackend)
+ return backend, ok
+}