aboutsummaryrefslogtreecommitdiff
path: root/state/memory_backend.go
diff options
context:
space:
mode:
authorsangtran <tranquangsang12.7@gmail.com>2026-08-31 23:51:37 +0700
committersangtran <tranquangsang12.7@gmail.com>2026-08-31 23:51:37 +0700
commit6631d8b00e8c5bafea15ea24415c5b55439193ee (patch)
treea320af141ba14bb02c669dbccbf00bcc850c6dbb /state/memory_backend.go
parent96c07bab1086510a55a004e9a1b90c30bc723a5c (diff)
signatureVerified sangtran <tranquangsang12.7@gmail.com> Key: 8DD79823D235E1BB ultimate trust
downloadflux-6631d8b00e8c5bafea15ea24415c5b55439193ee.tar.gz
flux-6631d8b00e8c5bafea15ea24415c5b55439193ee.zip
Verified bug: fix memory_state clear and guard window state empty with implement main.go for test
Diffstat (limited to 'state/memory_backend.go')
-rw-r--r--state/memory_backend.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/state/memory_backend.go b/state/memory_backend.go
index 6594657..f4043a1 100644
--- a/state/memory_backend.go
+++ b/state/memory_backend.go
@@ -2,6 +2,7 @@ package state
2 2
3import ( 3import (
4 "context" 4 "context"
5
5 "flux/core" 6 "flux/core"
6) 7)
7 8
@@ -11,9 +12,9 @@ import (
11// This should be optimize with ZERO GC Scanning, Memory Alignment 12// This should be optimize with ZERO GC Scanning, Memory Alignment
12 13
13type MemoryStateBackend struct { 14type MemoryStateBackend struct {
14 maxParallelism int 15 maxParallelism int
15 currentKey string 16 currentKey string
16 currentGroupKey int 17 currentGroupKey int
17 currentNamespace any 18 currentNamespace any
18 // 4D structure StateName -> KeyGroup -> Key -> Namespace -> Value 19 // 4D structure StateName -> KeyGroup -> Key -> Namespace -> Value
19 states map[string]map[int]map[string]map[any]any 20 states map[string]map[int]map[string]map[any]any
@@ -36,18 +37,18 @@ func (ms *MemoryStateBackend) SetCurrentKey(key string) error {
36 return nil 37 return nil
37} 38}
38 39
39func (ms *MemoryStateBackend) GetValueState(ctx context.Context, key string) (core.ValueState[any], error) { 40func (ms *MemoryStateBackend) GetValueState(ctx context.Context, statename string) (core.ValueState[any], error) {
40 // Assign if state not existed 41 // Assign if state not existed
41 42
42 if _, ok := ms.states[key]; !ok { 43 if _, ok := ms.states[statename]; !ok {
43 ms.states[key] = make(map[int]map[string]map[any]any) 44 // create state name map if not existed
45 ms.states[statename] = make(map[int]map[string]map[any]any)
44 } 46 }
45 47
46 return &memoryStateValue{backend: ms, stateName: key}, nil 48 return &memoryStateValue{backend: ms, stateName: statename}, nil
47} 49}
48 50
49func (ms *MemoryStateBackend) GetCurrentNamespace() any{ 51func (ms *MemoryStateBackend) GetCurrentNamespace() any {
50
51 return ms.currentNamespace 52 return ms.currentNamespace
52} 53}
53 54