Refactor: Migrate workflow memory context store to pkg/cache
- 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.**
Runtime workflow data (backoff counts, next execute time, failed-times, and other in-memory keys) lives in `pkg/context/context.go` behind:
- `workflowMemoryCache sync.Map` (per workflow instance key)
- per-instance `memoryStore *sync.Map`
Cleanup goes through `CleanupMemoryStore`. This should migrate to `github.com/kubevela/pkg/cache` so runtime memory context uses the shared cache package like StepStatusCache and the HTTP rate limiter.
**Describe the solution you'd like**
Migrate `workflowMemoryCache` / `memoryStore` to `github.com/kubevela/pkg/cache`:
- Preserve Get / Set / Increase / Delete / `CleanupMemoryStore` semantics used by the executor and controllers.
- Keep primary-store behavior: entries remain for the life of the running workflow and are removed by explicit cleanup, not by TTL sweep or capacity eviction of hot keys.
- No change to backoff / scheduling behavior under normal reconcile load.
- Extend unit tests around memory helpers and cleanup.
Depends on a released `github.com/kubevela/pkg` version that includes the cache package used by #240 / #249.
**Describe alternatives you've considered**
- Keep nested `sync.Map`s indefinitely. Works today, but stays outside the shared cache direction.
- TTL or LRU without pinning active workflow keys. Rejected: can lose backoff / scheduling state mid-run.
**Additional context**
- Code: `pkg/context/context.go` (`workflowMemoryCache`, `memoryStore`, `CleanupMemoryStore`).
- Related: #239 / #240, #247 / #249, kubevela/pkg#130 / #136 / #138.
- Sibling migrations: email `sync.Map`, optional in-memory context storage, CUE compat alignment.
- Good first issue with care: touch points are localized, but this is hot runtime state; tests around cleanup and backoff keys matter.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in pkg/context/context.go with workflowMemoryCache, memoryStore, and CleanupMemoryStore, then compare the shared cache usage in StepStatusCache and the HTTP rate limiter. Preserve Get, Set, Increase, Delete, and explicit cleanup behavior without TTL or eviction of active workflow state; extend the unit tests around memory helpers, cleanup, and backoff keys.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100