Skip to content

Commit

Permalink
Fix middlewares order for publishing scope
Browse files Browse the repository at this point in the history
  • Loading branch information
sheldygg committed Nov 23, 2024
1 parent 9bc7a05 commit e6c3007
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions faststream/broker/core/usecase.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ async def publish(

publish = producer.publish

for m in self._middlewares:
for m in self._middlewares[::-1]:
publish = partial(m(None).publish_scope, publish)

return await publish(msg, correlation_id=correlation_id, **kwargs)
Expand All @@ -359,7 +359,7 @@ async def request(
assert producer, NOT_CONNECTED_YET # nosec B101

request = producer.request
for m in self._middlewares:
for m in self._middlewares[::-1]:
request = partial(m(None).publish_scope, request)

published_msg = await request(
Expand All @@ -370,7 +370,7 @@ async def request(

async with AsyncExitStack() as stack:
return_msg = return_input
for m in self._middlewares:
for m in self._middlewares[::-1]:
mid = m(published_msg)
await stack.enter_async_context(mid)
return_msg = partial(mid.consume_scope, return_msg)
Expand Down

0 comments on commit e6c3007

Please sign in to comment.