-
-
Notifications
You must be signed in to change notification settings - Fork 522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Commit arbitrary offset #235
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks fine to me. It does feel a little weird to overload commitOffsetsIfNecessary
in this way, but I don't really have a better solution. Exposing commitOffsets
(with the ability to provide arbitrary offsets) I feel would worsen the ergonomics, since you'd have to know a lot about the internals to understand why it doesn't respect your commit thresholds.
await runner.start() | ||
await runner.fetch() // Manually fetch for test | ||
|
||
expect(eachBatch).toHaveBeenCalledWith({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we only care about commitOffsetsIfNecessary
in this test, I would suggest changing this to expect it to have been called with expect.objectContaining({ commitOffsetsIfNecessary: expect.any(Function) })
, so that this won't start failing just because we added something to the signature of eachBatch
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point, I'll change :)
@Nevon Since the user only knows about the behavior of the exposed I do think there is still an argument for exposing a |
Addresses #122 by allowing users to provide offsets to the
commitOffsetsIfNecessary
method in theeachBatch
callback.Basically the existing API has no interface for committing an arbitrary offset outside a transaction. The recent transactional work in #232 adds an API for transactions to send offsets as participants in a transaction, but that doesn't help if the user wants to commit an offset without opening a transaction.
I'm open to hearing alternatives for exposing this functionality. This seemed the least disruptive for the existing API.