fix: implement WriteApi.flush() for batching mode - #714
Open
sankalpsthakur wants to merge 1 commit into
Open
Conversation
WriteApi.flush() was documented as a stable API but was a TODO no-op. Implement it by adding a flush boundary subject that forces the current batch window to close, matching the C#/Java batch writer design. - Flush sends pending points without waiting for batch_size/flush_interval - WriteApi remains usable after flush (unlike close()) - No-op for synchronous/asynchronous write types - Unit tests for partial batch, reuse, empty buffer, and sync mode Fixes influxdata#697
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #714 +/- ##
==========================================
+ Coverage 90.38% 90.43% +0.04%
==========================================
Files 40 40
Lines 3546 3554 +8
==========================================
+ Hits 3205 3214 +9
+ Misses 341 340 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed Changes
WriteApi.flush()was documented as a stable API but implemented as aTODO/passno-op (#697).This implements
flush()for batching mode by adding a flush boundary subject that forces the current batch window to close and send pending points over HTTP — the same approach used by the C# and Java client batch writers.Behavior
batch_sizeorflush_interval)WriteApiremains usable afterflush()(unlikeclose())Implementation notes
ops.publish+ops.window(rx.merge(time/count windows, flush_subject)), mirroring C# WriteApi / JavaFlowableBufferTimedFlushablebatch.size > 0filter)Fixes #697
Checklist
pytest tests/test_WriteApiBatching.pycompletes successfully (new flush tests + existing batching tests)Tests
New coverage:
test_flush_partial_batch— single point underbatch_sizeis written onflush()test_flush_allows_reuse— further writes work afterflush()test_flush_empty_is_noop— empty buffer does not HTTPtest_flush_synchronous_is_noop— sync mode does not raiseAI disclosure
AI assistance was used to locate the incomplete
flush()stub, compare C#/Java batch-writer flush designs, draft the Rx boundary-window change, and write unit tests. The change was reviewed, kept scoped to the batching pipeline + tests + changelog, and verified with the batching unit tests above.AI/LLM disclosure