Feature: Unify the middleware interface between Broker and subscriber/publisher #1646
Labels
Core
Issues related to core FastStream functionality and affects to all brokers
enhancement
New feature or request
Milestone
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.
The text was updated successfully, but these errors were encountered: