-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Flip email queuing paradigm around (breaking change) #154
Comments
After thinking on this, I wonder if both paths can't coexist, at least for a little while. So keep the |
It would make this not a breaking change for now, which would be nice. We could mark the router as deprecated, slated for removal in some future release. It could give people time to migrate, if there are people using this application besides @westerveltco. Selfishly, it would make it easier for me to migrate all of our apps to the new way of handling the email queue. |
Let's queue up some time to discuss it next week.
"Each application uses its own default database for queuing emails" I thought we were already doing this. "relay service connects to each one to get queued emails to send." - I personally wouldn't want to do this. I think we should figure out what is problematic or weird about the existing setup, and ideally, every email should be sent immediately. If there is an issue, having a queued backup with some history is reasonable. We should also think about the volume of email sent per project. Are we looking at 2, 20, 200, or 2000 emails per day, and is that worth keeping constant connections open? Maybe you want the service behind the firewall to only talk with one service outside of the firewall that everything else can relay through which would cut down the O(n) connection issues on either side? |
Status Quo
Right now each application connects to a central database and uses a database router to make sure sent emails end up in that central database. This has been working fine, but there are some downsides:
application_id
to theMessage
model and have each application register itself with a unique id. Then in the admin filter just the application's emails, but I don't love that as it's adding and spreading even more complexity around (see the previous point). How are the ids generated? How is each application registered with the relay service? Etc.I wrote this library to solve a very specific problem we have at work. We have our applications running where they cannot access our corporate internal SMTP server. Using an external ESP was not feasible as the various spam and security features of our email provider were flagging our applications' emails.
I chose a database queue because I wanted something robust that was (relatively) simple to run. At the time I was not interested in running another service e.g. a message queue like Redis or RabbitMQ. But that may change in the future and adding support for that in this library as it's currently designed would be non-trivial. (YAGNI of course, so this is not the ultimate goal of what I'm proposing, but would be a nice side-effect.)
Proposal
I think instead of each application and the relay service using on central database, instead it should be flipped around the other way. Each application uses its own default database for queuing emails and the relay service connects to each one to get queued emails to send.
When I first had this thought, I dismissed it as a bit silly and me looking for a way to over engineer something (which I am wont to do). But as I've sat with the idea, I do think it solves a lot of the problems with the current state of things:
Using this approach would make the relay service much more complex than it currently is, so it's not all upside. The service would need to connect to each application's database somehow, so it would need to know where the database is and would need to be accessible from wherever the service is running. It would shift the complexity of the version upgrades from a coordination issue to a logic issue within the service itself. But those tradeoffs may be worth it. 🤷♂️
Gathering Feedback
This would be quite a big breaking change from how the library works and I'm not totally sold on it yet, but something needs to change and this is what I've come up with at the moment.
To be honest, I'm not even sure how many if any users actually use this library. According to pypistats.org it does get a non-zero amount of installs, but I have no way how many of those are our own vs automated bot services vs actual users.
I'm opening this issue to gather feedback for this proposal and pinning it. I will more than likely be following through with this, but I still need time to consider all the sides to it. If there are users that have issues with this proposal, this is the place to post them. I'm open to any honest feedback, but since this library is primarily written to solve a very specific problem for the company I work for, I can't promise anything other than I will listen.
The text was updated successfully, but these errors were encountered: