diff options
Diffstat (limited to 'state/memory_backend.go')
| -rw-r--r-- | state/memory_backend.go | 21 |
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 | ||
| 3 | import ( | 3 | import ( |
| 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 | ||
| 13 | type MemoryStateBackend struct { | 14 | type 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 | ||
| 39 | func (ms *MemoryStateBackend) GetValueState(ctx context.Context, key string) (core.ValueState[any], error) { | 40 | func (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 | ||
| 49 | func (ms *MemoryStateBackend) GetCurrentNamespace() any{ | 51 | func (ms *MemoryStateBackend) GetCurrentNamespace() any { |
| 50 | |||
| 51 | return ms.currentNamespace | 52 | return ms.currentNamespace |
| 52 | } | 53 | } |
| 53 | 54 | ||
