From 6631d8b00e8c5bafea15ea24415c5b55439193ee Mon Sep 17 00:00:00 2001 From: sangtran Date: Mon, 31 Aug 2026 23:51:37 +0700 Subject: bug: fix memory_state clear and guard window state empty with implement main.go for test --- state/memory_backend.go | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'state/memory_backend.go') 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 import ( "context" + "flux/core" ) @@ -11,9 +12,9 @@ import ( // This should be optimize with ZERO GC Scanning, Memory Alignment type MemoryStateBackend struct { - maxParallelism int - currentKey string - currentGroupKey int + maxParallelism int + currentKey string + currentGroupKey int currentNamespace any // 4D structure StateName -> KeyGroup -> Key -> Namespace -> Value states map[string]map[int]map[string]map[any]any @@ -36,18 +37,18 @@ func (ms *MemoryStateBackend) SetCurrentKey(key string) error { return nil } -func (ms *MemoryStateBackend) GetValueState(ctx context.Context, key string) (core.ValueState[any], error) { +func (ms *MemoryStateBackend) GetValueState(ctx context.Context, statename string) (core.ValueState[any], error) { // Assign if state not existed - - if _, ok := ms.states[key]; !ok { - ms.states[key] = make(map[int]map[string]map[any]any) + + if _, ok := ms.states[statename]; !ok { + // create state name map if not existed + ms.states[statename] = make(map[int]map[string]map[any]any) } - return &memoryStateValue{backend: ms, stateName: key}, nil + return &memoryStateValue{backend: ms, stateName: statename}, nil } -func (ms *MemoryStateBackend) GetCurrentNamespace() any{ - +func (ms *MemoryStateBackend) GetCurrentNamespace() any { return ms.currentNamespace } -- cgit v1.3.1