-
Notifications
You must be signed in to change notification settings - Fork 36
feat: Add configurable page-size parameter to fga tuple read
command
#571
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
Conversation
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds page-size support to tuple reads: introduces a --page-size flag, updates defaulting logic (100 when max-pages=0, else 50), threads pageSize through the CLI to internal tuple.Read, and updates the tuple.Read signature to accept pageSize. Also updates a store export call-site to pass an explicit default page size. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor U as User
participant CLI as fga tuple read (CLI)
participant Resolver as PageSize Resolver
participant T as internal/tuple.Read
participant SDK as OpenFGA SDK
U->>CLI: run "fga tuple read [--max-pages N] [--page-size P]"
CLI->>Resolver: compute pageSize (N, P)
alt P provided (>0)
Note right of Resolver: Use P
else P not provided (0)
alt N == 0
Note right of Resolver: pageSize = 100
else N > 0
Note right of Resolver: pageSize = 50
end
end
Resolver-->>CLI: pageSize
CLI->>T: Read(ctx, req, maxPages=N, pageSize, consistency)
T->>SDK: Read(req, options{PageSize: pageSize}, paging)
SDK-->>T: tuples (+continuation)
T-->>CLI: aggregated response
CLI-->>U: output tuples
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Assessment against linked issues
Assessment against linked issues: Out-of-scope changes
Suggested labels
Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
Also would you mind updating the read section in the README?
28bab45
to
5de5a89
Compare
Thanks! |
Description
This PR enhances the
fga tuple read
command by adding support for a configurablepage-size
parameter and implementing intelligent default page-size behavior based on themax-pages
setting to improve performance when reading tuples.Related Issue
Fixes #568
Changes made
--page-size
flag to thefga tuple read
commandmax-pages=0
(read all tuples): defaults to 100 for better efficiencymax-pages!=0
(limited pages): defaults to 50 to maintain backward compatibility--page-size
is explicitly specified: uses the provided valuetuple.Read
function to accept page size as a parametercmd/store/export.go
to use the appropriate page sizeCommand usage examples
1. Read all tuples (optimized with page-size=100)
Command:
fga tuple read --store-id=01H0H015178Y2V4CX10C2KGHF4 --max-pages=0
Output:
2. Read with limited pages (default page-size=50)
Command:
fga tuple read --store-id=01H0H015178Y2V4CX10C2KGHF4 --max-pages=2 --user user:anne
Output:
3. Read with custom page size
Command:
fga tuple read --store-id=01H0H015178Y2V4CX10C2KGHF4 --max-pages=3 --page-size=75 --relation viewer
Output:
4. Help output showing new flag
Command:
fga tuple read --help
Output (relevant section):
Performance Impact
For stores with many tuples, this change significantly reduces API calls when reading all tuples:
No breaking changes
This PR does not include breaking changes.
The default behavior when
max-pages!=0
remains unchanged (page-size=50), ensuring complete backward compatibility.Summary by CodeRabbit