Feature: Handover the message for the middleware for the on_receive
method
#2070
Labels
enhancement
New feature or request
on_receive
method
#2070
Is your feature request related to a problem? Please describe.
So implemented a middleware that injects the correlation id of the message to my loggers via contextvars. Initially I used the
on_consume
andafter_consume
for this. However the issue was that in case an error happend at input validation then my logger wouldn't have the correlation_id sinceon_consume
seems to happen after input validation.So now I'm using
on_receive
andafter_processed
. However for these message I only have access to the middleware via instanceattributeself.msg
. The issue with this one is the type. In theBaseMiddleware
we haveself.msg: Optional[Any]
. So since I can't really expect anything from it, I have to do ugly checks for if the msg isn'tNone
and of a specific type.Describe the solution you'd like
So it would be more convenient if this function could have a similar interface as
on_consume
or the typing ofself.msg
could be more specific.Describe alternatives you've considered
For now I'm doing the ugly checks :D
The text was updated successfully, but these errors were encountered: