Skip to content

Refactor: Migrate email routine sync.Map to pkg/cache #253

Description

@roguepikachu

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions