Skip to content
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

Invert execution orders of post, on_error and shutdown middleware hooks #359

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hawang-wish
Copy link
Contributor

Hi,

I've further noticed that we could introduce a slight improvement to make middlewares follow the "onion" execution order. For example, if a message is wrapped with pre_send of multiple middlewares, it's generally better to run post_send in reversed order.

I've then inverted the order of post_execute, shutdown, on_error, and post_save so that all existing middleware hooks have an onion-ish invoke order.

A practical use case is that some of my middlewares do modifications to add a mark in pre_send and remove it in post_send. However, without this improvement I couldn't make the mark invisible to other middlewares.

The unit tests I added could fail because of other issues: #358 and #357

As always, let me know if you have suggestions or concerns, and thanks for the review in advance!

@s3rius
Copy link
Member

s3rius commented Nov 6, 2024

Please fix lints and tests before the review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants