Add limit iterator and context plumbing for --limit flag#4790
Draft
simonfaltum wants to merge 4 commits intomainfrom
Draft
Add limit iterator and context plumbing for --limit flag#4790simonfaltum wants to merge 4 commits intomainfrom
simonfaltum wants to merge 4 commits intomainfrom
Conversation
Return listing.ErrNoMoreItems when Next() is called with remaining <= 0, so the limit is enforced even if the caller skips HasNext().
…ed plumbing Remove the context-based limit mechanism (WithLimit, GetLimit, ApplyLimit and limitIterator) from libs/cmdio. The limit will now be applied at the callsite by wrapping the iterator with listing.NewLimitIterator from the SDK, keeping the render functions clean and decoupled from limit logic. Co-authored-by: Isaac
Collaborator
|
Commit: 2798fb3
18 interesting tests: 9 SKIP, 6 RECOVERED, 3 flaky
Top 25 slowest tests (at least 2 minutes):
|
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.
Why
The codegen template generates a
--limitflag on every paginated list command. The generated code needs runtime plumbing to cap total results returned by iterators.Changes
Before: no mechanism to cap total results from list commands.
Now: uses
listing.NewLimitIteratorfrom the SDK to wrap iterators at the callsite, capping output to N items.This is a v2 of #4724, refactored per Pieter's feedback to move the limit iterator into the SDK (
databricks/databricks-sdk-go#1555) and apply it at the callsite instead of using context-based plumbing.What changed from v1
libs/cmdio/limit.go(context-basedWithLimit/GetLimit/ApplyLimit)libs/cmdio/limit_test.goRenderIterator*functions no longer callApplyLimit, they are clean pass-through renderers againlisting.NewLimitIterator(iter, n)(SDK-level)Blocked on
go.modhas a temporaryreplacedirective pointing to the SDK branch commit. Must be swapped for the official SDK version once merged and released.listing.NewLimitIteratorat the callsite (separate follow-up)Test plan
NewLimitIteratorare in the SDK PRgo test ./libs/cmdio/...passesgo build ./...passes