Skip to content
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

feat: add ListUsers configuration options #1572

Merged
merged 4 commits into from Apr 26, 2024

Conversation

miparnisari
Copy link
Member

@miparnisari miparnisari commented Apr 25, 2024

Description

Support three new configs for ListUsers:

  • maxResults. If zero, we will try to retrieve all of them
  • deadline. If zero, no deadline
  • maxConcurrentReads. If zero, error.

TO DO: update benchmark introduced in #1555

Testing

# help test
[25/04/24 5:08:44] ~/GitHub/openfga (list-users-config-options) $ ./dist/openfga run --help | grep "[uU]sers"
      --experimentals enable-list-users                          a list of experimental features to enable. Allowed values: enable-list-users
      --listUsers-deadline duration                              the timeout deadline for serving ListUsers requests. If 0, there is no deadline (default 3s)
      --listUsers-max-results uint32                             the maximum results to return in non-streaming ListUsers API responses. If 0, all results can be returned (default 1000)
      --max-concurrent-reads-for-list-users uint32               the maximum allowed number of concurrent datastore reads in a single ListUsers query. A high number will consume more connections from the datastore pool and will attempt to prioritize performance for the request at the expense of other queries performance. (default 4294967295)

# validation of config options
[25/04/24 5:23:11] ~/GitHub/openfga (list-users-config-options) $ ./dist/openfga run --datastore-engine=memory
 --experimentals enable-list-users --max-concurrent-reads-for-list-users 0 --listUsers-max-results  1
 🚀  Building the OpenFGA binary within /Users/maria.inesparnisari/GitHub/openfga/dist/openfga  
panic: config 'maxConcurrentReadsForListUsers' cannot be 0

goroutine 1 [running]:
github.com/openfga/openfga/cmd/run.run(0x140000e6100?, {0x140003b0150?, 0x4?, 0x104cab275?})
        /Users/maria.inesparnisari/GitHub/openfga/cmd/run/run.go:256 +0xd8
github.com/spf13/cobra.(*Command).execute(0x140003e6300, {0x140003b00e0, 0x7, 0x7})
        /Users/maria.inesparnisari/go-mod-cache/github.com/spf13/cobra@v1.8.0/command.go:987 +0x828
github.com/spf13/cobra.(*Command).ExecuteC(0x140003e6000)
        /Users/maria.inesparnisari/go-mod-cache/github.com/spf13/cobra@v1.8.0/command.go:1115 +0x344
github.com/spf13/cobra.(*Command).Execute(0x140003e6000?)
        /Users/maria.inesparnisari/go-mod-cache/github.com/spf13/cobra@v1.8.0/command.go:1039 +0x1c
main.main()
        /Users/maria.inesparnisari/GitHub/openfga/cmd/openfga/main.go:28 +0x108
[25/04/24 5:23:24] ~/GitHub/openfga (list-users-config-options) $ 


# enforcement of max results
[25/04/24 5:23:52] ~/GitHub/openfga (list-users-config-options) $ make build &&  ./dist/openfga run --datastore-engine=memory --experimentals enable-list-users --max-concurrent-reads-for-list-users 1 --listUsers-max-results  1
 
// ... 

2024-04-25T17:24:09.615-0700    INFO    grpc_req_complete       {"grpc_service": "openfga.v1.OpenFGAService", "grpc_method": "ListUsers", "grpc_type": "unary", "request_id": "07e3b5bd-e39b-4726-95ea-4b209659f695", "user_agent": "PostmanRuntime/7.37.3", "raw_request": {"store_id":"01HV73AN9K9SVX8HG1FPPNZZSY","authorization_model_id":"","object":{"type":"group","id":"target"},"relation":"member","user_filters":[{"type":"user","relation":""}],"contextual_tuples":[],"context":null}, "raw_response": {"users":[{"object":{"type":"user","id":"a"}}],"excluded_users":[]}, "peer.address": "127.0.0.1:56116", "store_id": "01HV73AN9K9SVX8HG1FPPNZZSY", "authorization_model_id": "01HWBWKD6ZAG702PHTAGCRVH19", "grpc_code": 0}

@miparnisari miparnisari marked this pull request as ready for review April 26, 2024 00:25
@miparnisari miparnisari requested a review from a team as a code owner April 26, 2024 00:25
@willvedd willvedd merged commit 4954cd6 into list-users Apr 26, 2024
5 checks passed
@willvedd willvedd deleted the list-users-config-options branch April 26, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants