You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Summary**
Currently every transactional email fetches its template inside
transactions. This adds request latency, blocks database transactions,
and causes user visible failures when the template service is slow or
unavailable.
This pr will address these issues in 3 phases:
1. **Baseline decomposition (this PR)**
* Untangle the mailer into layered, single-purpose packages
(`mailmeclient`, `noopclient`, `validateclient`, `taskclient`,
`templatemailer`).
* Simplify API construction with a single `newMailer()` factory inside
the api package to composes the pipeline.
* No behavioral changes, this is strictly restructuring to make follow
ups easier.
2. **Template cache + interface refactor (upcoming)**
* Fix the race conditions in the template caching system.
* Add methods for the background template reloader to refresh the cache.
* Redefine the low-level mail client interface to only accept `(to,
subject, body, headers)` while `templatemailer` owns all templating
logic.
* Introduce some configuration parameters for tuning.
3. **Introduce background template reloading**
* Add a worker at startup similar to the previous PR for background
workers.
* Periodically update the cache at a configurable interval.
* Notify the template reloader to update when config reloads occur.
* Remove blocking calls to the template cache unless a cache miss
occurs.
* Never drop a template from cache before having an updated entry.
---------
Co-authored-by: Chris Stockton <[email protected]>
0 commit comments