Skip to content

Commit

Permalink
Refectored Code slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
sifex committed May 18, 2024
1 parent e77be6c commit fff8a92
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
13 changes: 1 addition & 12 deletions faststream/confluent/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,21 +109,10 @@ async def publish( # type: ignore[override]
return_value = None

for handler in self.broker._subscribers.values(): # pragma: no branch
call = False

# for p in handler.partitions:
# if p.topic == topic and (partition is None or p.partition == partition):
# call = True

if topic in handler.topics:
call = True

if call:
handle_value = await call_handler(
handler=handler,
message=[incoming]
if isinstance(handler, AsyncAPIBatchSubscriber)
else incoming,
message=[incoming] if isinstance(handler, AsyncAPIBatchSubscriber) else incoming,
rpc=rpc,
rpc_timeout=rpc_timeout,
raise_timeout=raise_timeout,
Expand Down
18 changes: 5 additions & 13 deletions faststream/kafka/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,21 +108,13 @@ async def publish( # type: ignore[override]
return_value = None

for handler in self.broker._subscribers.values(): # pragma: no branch
call = False

for p in handler.partitions:
if p.topic == topic and (partition is None or p.partition == partition):
call = True

if topic in handler.topics:
call = True

if call:
if any(
p.topic == topic and (partition is None or p.partition == partition)
for p in handler.partitions
) or topic in handler.topics:
handle_value = await call_handler(
handler=handler,
message=[incoming]
if isinstance(handler, AsyncAPIBatchSubscriber)
else incoming,
message=[incoming] if isinstance(handler, AsyncAPIBatchSubscriber) else incoming,
rpc=rpc,
rpc_timeout=rpc_timeout,
raise_timeout=raise_timeout,
Expand Down

0 comments on commit fff8a92

Please sign in to comment.