-
Notifications
You must be signed in to change notification settings - Fork 39
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 (
|
rhamzeh
left a comment
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 readcommand by adding support for a configurablepage-sizeparameter and implementing intelligent default page-size behavior based on themax-pagessetting to improve performance when reading tuples.Related Issue
Fixes #568
Changes made
--page-sizeflag to thefga tuple readcommandmax-pages=0(read all tuples): defaults to 100 for better efficiencymax-pages!=0(limited pages): defaults to 50 to maintain backward compatibility--page-sizeis explicitly specified: uses the provided valuetuple.Readfunction to accept page size as a parametercmd/store/export.goto 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=0Output:
{ "tuples": [ { "key": { "user": "user:anne", "relation": "reader", "object": "document:roadmap" }, "timestamp": "2024-01-15T10:30:00Z" }, { "key": { "user": "user:bob", "relation": "writer", "object": "document:design" }, "timestamp": "2024-01-15T10:31:00Z" } // ... fetches up to 100 tuples per page instead of 50 ], "continuation_token": "" }2. Read with limited pages (default page-size=50)
Command:
fga tuple read --store-id=01H0H015178Y2V4CX10C2KGHF4 --max-pages=2 --user user:anneOutput:
{ "tuples": [ { "key": { "user": "user:anne", "relation": "reader", "object": "document:roadmap" }, "timestamp": "2024-01-15T10:30:00Z" }, { "key": { "user": "user:anne", "relation": "viewer", "object": "folder:projects" }, "timestamp": "2024-01-15T10:32:00Z" } // ... up to 50 tuples per page (maintains backward compatibility) ], "continuation_token": "" }3. Read with custom page size
Command:
fga tuple read --store-id=01H0H015178Y2V4CX10C2KGHF4 --max-pages=3 --page-size=75 --relation viewerOutput:
{ "tuples": [ { "key": { "user": "user:anne", "relation": "viewer", "object": "folder:projects" }, "timestamp": "2024-01-15T10:32:00Z" }, { "key": { "user": "user:bob", "relation": "viewer", "object": "folder:shared" }, "timestamp": "2024-01-15T10:33:00Z" } // ... fetches up to 75 tuples per page as specified ], "continuation_token": "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTUUoyN01MdTdqTjh0Ym42MjA4In0=" }4. Help output showing new flag
Command:
fga tuple read --helpOutput (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!=0remains unchanged (page-size=50), ensuring complete backward compatibility.Summary by CodeRabbit