-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert commitAsync callback handling to ZIO sooner (#1404)
KafkaConsumer's `commitAsync` takes a callback, which we program against with complicated followup code. This PR attempts to convert everything to ZIO's earlier on, making chaining followup effects easier to reason about. As this changes some functionality around locking and same / single threads, here's a summary of what do we need to ensure: * We have an exclusive lock on the consumer when calling `commitAsync`. In `Runloop.run` this is done using `ConsumerAccess`. In the rebalance coordinator (while rebalancing) we already have the lock as we're calling `poll()` so no need for extra locking. * The consumer is not used from more than one thread at the same time. For use in `Runloop.run` we get this for free by guaranteeing exclusive access. In the rebalance coordinator a `poll()` call is in the middle of being executed and we need to call `commitAsync` on the same thread as the rebalance listener is invoked. Anything that is not calling commitAsync is free to run on any thread as executed by the default ZIO runtime. --------- Co-authored-by: Erik van Oosten <e.vanoosten@grons.nl>
- Loading branch information
1 parent
e689977
commit 4a0176f
Showing
7 changed files
with
198 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.