Add priority field to server #3446
Add priority field to server #3446amirhasanzadehpy wants to merge 2 commits intopostalserver:mainfrom
Conversation
…d job processing logic
|
This PR resolves https://github.com/orgs/postalserver/discussions/1491 |
|
I like the idea of this. I'll look at testing and merging this shortly. |
I was wondering if there’s any update or feedback on this PR. |
|
Hi @adamcooke, just checking in to see if you’ve had a chance to review this yet. Happy to make any adjustments if needed! Thanks again for taking a look. |
|
This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
|
This is a very useful feature and should not be closed. |
Adds a priority field to servers that controls the order in which queued messages are processed. Messages from servers with higher priority values are sent first. Includes: - Database migration to add priority column - Validation for priority (0-32767) - UI field in server form - Queue ordering by server priority Cherry-picked from postalserver/postal PR postalserver#3446 Co-authored-by: Xyaren <Xyaren@users.noreply.github.com> Co-authored-by: openhands <openhands@all-hands.dev>
|
Great idea, but my concern is that the implementation needs to be more sophisticated: imagine you have X emails with server priority 2 and Y emails with server priority 1. With a simple approach, none of the Y emails would be processed until all X emails are sent. The solution is straightforward, similar to how operating systems manage CPU time: we should process messages while allocating more execution time to higher priority emails. UPD: something like this #1422 |
@kirik That is exactly what we need in our use case. We want to give higher priority to transactional emails, and no marketing email to be processed until all transactional emails are sent (sign up email verification, forget password, short-lived OTPs, ...). |
This introduces a server-level priority system to allow for more granular control over the message queue. By assigning a numerical priority to each mail server (with a higher number indicating higher priority), administrators can ensure that time-sensitive transactional emails are processed ahead of bulk newsletters or other less critical mail. This change modifies the message dequeuing logic to sort by server priority before the message ID, ensuring that all high-priority messages are sent first, while maintaining a fair first-in, first-out order for messages of the same priority. The feature is implemented with a default priority of 0 for all existing and new servers, making it a non-disruptive change that can be optionally configured after deployment.