Open andreaimprovised opened 1 month ago
Thank you for the suggestion! I am still designing some breaking changes to release in 0.6.0 and subscriber & publisher middlewares rework is one of them. I'll contact you here, when we have some final view about middlewares.
Is your feature request related to a problem? Please describe.
Yes.
The API protocol/types for middleware dare different for Broker/Router instantiation vs. subscriber/publisher instantiation.
These are the current types in faststream/broker/types.py:
The subscriber/publisher middleware API is specific to the consume_scope and publish_scope signatures.
This is a bit surprising. It makes
faststream.broker.middleware.BaseMiddleware
only work for brokers. As a result, the middleware is not really portable.Describe the solution you'd like
Make the subscriber/publisher protocols the same as the broker/router protocols.
Or, perhaps, allow both? Or at least document on the website that there's a difference.
Feature code example This is what I wish were possible.
Describe alternatives you've considered
There is an adapter strategy, but it's a little extra effort and more indirection.
Additional context Include any other relevant context or screenshots related to the feature request.