Refactor: Migrate email routine sync.Map 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.**
The email provider keeps send-state in a process-local `sync.Map` (`emailRoutine`) in both:
- `pkg/providers/email/email.go`
- `pkg/providers/legacy/email/email.go`
That map tracks per-id states such as `initializing` / `sending` / `success` / error so a reconcile can avoid starting a second send for the same email id. After StepStatusCache (#239 / #240) and the HTTP rate limiter (#247 / #249) moved onto `github.com/kubevela/pkg/cache`, this remaining `sync.Map` should use the same shared cache package for consistency.
**Describe the solution you'd like**
Migrate `emailRoutine` to `github.com/kubevela/pkg/cache` in both email packages:
- Replace `sync.Map` with the shared cache API (`Get` / `Put` / `Delete`).
- Preserve send-once semantics: do **not** use a short TTL that can drop in-flight or recently-sent ids and cause duplicate emails. Prefer explicit Delete on completion / failure, or a TTL that is safely longer than any realistic send window only if still correct.
- Keep public email provider behavior unchanged.
- Add or extend unit tests for both non-legacy and legacy paths covering initializing / sending / success / error and no double-send.
Depends on a released `github.com/kubevela/pkg` version that includes the cache package used by #240 / #249.
**Describe alternatives you've considered**
- Keep `sync.Map` indefinitely. Works today, but leaves another bespoke store outside the shared cache direction.
- Use entry-count LRU with aggressive eviction. Rejected unless keys stay pinned for the full send lifetime; eviction must not cause duplicate sends.
**Additional context**
- Related: #239 / #240 (StepStatusCache), #247 / #249 (HTTP rate limiter), kubevela/pkg#130 / #136 / #138.
- Sibling migrations: optional in-memory context storage, workflow memory context store, CUE compat alignment.
- Good first issue: localized to the email provider packages; main risk to watch is duplicate sends under TTL/eviction.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.