kubevela / kubevela/workflow

Refactor: Migrate optional in-memory context storage to pkg/cache

Open
#254 0 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue help wanted
Dominant language
Go
Stars
126
Forks
66
Avg merge
1h 40m
Merged PRs (30d)
1

Description

**Is your feature request related to a problem? Please describe.**
When `EnableInMemoryContext` is on, workflow keeps context ConfigMaps in process memory via `MemStore` in `pkg/context/storage.go` (`map[string]*v1.ConfigMap` plus a mutex). That hand-rolled store should move onto `github.com/kubevela/pkg/cache` so optional in-memory context uses the same shared cache abstraction as the rest of the cache migrations.

**Describe the solution you'd like**
Migrate `inMemoryContextStorage` / `MemStore` to `github.com/kubevela/pkg/cache`:

- Preserve Get / Create / Update / Delete behavior in `pkg/context/storage.go`.
- Treat this as a store for live context when the feature is enabled, not a disposable tip cache: avoid TTL or LRU eviction that drops active workflow context unless paired with a correct reload strategy.
- Keep `EnableInMemoryContext` (default `false`) as the opt-in switch; no behavior change when disabled.
- Add or extend tests for enable/disable, create/update/get/delete, and concurrent access if applicable.

Depends on a released `github.com/kubevela/pkg` version that includes the cache package used by #240 / #249.

**Describe alternatives you've considered**
- Keep the plain map forever. Fine functionally, but inconsistent with the shared cache direction.
- Bound with LRU/TTL without a persistence story. Rejected: would drop live context for workflows using the optional path.

**Additional context**
- Code: `pkg/context/storage.go` (`EnableInMemoryContext`, `MemStore`).
- Related: #239 / #240, #247 / #249, kubevela/pkg#130 / #136 / #138.
- Sibling migrations: email `sync.Map`, workflow memory context store, CUE compat alignment.
- Good first issue: mostly confined to `pkg/context/storage.go`; verify optional flag paths carefully.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in pkg/context/storage.go by tracing EnableInMemoryContext and the MemStore Get/Create/Update/Delete paths, then inspect the released github.com/kubevela/pkg cache API required by the related migrations. Verify that disabled mode is unchanged and that enabled mode preserves CRUD behavior and safe concurrent access without TTL or LRU eviction; extend the context storage tests for these cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
backend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.