Skip to content

Commit

Permalink
Added manual commit to actual code
Browse files Browse the repository at this point in the history
  • Loading branch information
mephenor committed Feb 1, 2024
1 parent 29d13a0 commit 40c0453
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/hexkit/providers/akafka/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ def __init__( # noqa: PLR0913
"""
...

async def commit(self, offsets=None):
"""Commit offsets to Kafka Broker."""
...

async def start(self) -> None:
"""Setup the consumer."""
...
Expand Down Expand Up @@ -475,3 +479,4 @@ async def run(self, forever: bool = True) -> None:
else:
event = await self._consumer.__anext__()
await self._consume_event(event)
await self._consumer.commit()
5 changes: 2 additions & 3 deletions tests/integration/test_akafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,9 @@ async def test_consumer_commit_mode(kafka_fixture: KafkaFixture): # noqa: F811
consumer = cast(AIOKafkaConsumer, event_subscriber._consumer)

# check that the consumer is in manual commit mode
assert await consumer.committed(partition=partition) == None
assert not consumer._enable_auto_commit

# commit and check if the event reached the correct partition
await consumer.commit()
# check if the event was committed successfully
consumer_offset = await consumer.committed(partition=partition)
assert consumer_offset == 1

Expand Down

0 comments on commit 40c0453

Please sign in to comment.