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

Add ReadBulkRelationships API #2191

Closed

Conversation

kartikaysaxena
Copy link
Contributor

@kartikaysaxena kartikaysaxena commented Jan 7, 2025

This PR introduces support to ReadBulkRelationships API (first discussed here #2160)

It makes use of taskrunner for concurrent reads for the entire operation. The response is like

read_at: {
    token: "GhUKEzE3MzYyMjA2MzA5NjQ3NzMwMDA="
}
pairs: {
    request: {
        relationship_filter: {
            resource_type: "document"
            optional_resource_id: "document1"
            optional_relation: "reader"
            optional_subject_filter: {
                subject_type: "user"
            }
        }
    }
    item: {
        relationships: {
            resource: {
                object_type: "document"
                object_id: "document1"
            }
            relation: "reader"
            subject: {
                object: {
                    object_type: "user"
                    object_id: "user1"
                }
            }
        }
    }
}
pairs: {
    request: {
        relationship_filter: {
            resource_type: "document"
            optional_resource_id: "document2"
            optional_relation: "reader"
            optional_subject_filter: {
                subject_type: "user"
            }
        }
    }
    item: {
        relationships: {
            resource: {
                object_type: "document"
                object_id: "document2"
            }
            relation: "reader"
            subject: {
                object: {
                    object_type: "user"
                    object_id: "user2"
                }
            }
        }
    }
}
pairs: {
    request: {
        relationship_filter: {
            resource_type: "document"
            optional_resource_id: "document3"
            optional_relation: "reader"
            optional_subject_filter: {
                subject_type: "user"
            }
        }
    }
    item: {
        relationships: {
            resource: {
                object_type: "document"
                object_id: "document3"
            }
            relation: "reader"
            subject: {
                object: {
                    object_type: "user"
                    object_id: "user3"
                }
            }
        }
    }
}
after_result_cursor: {
    token: "Ck8KEzE3MzYyMjA2MzA5NjQ3NzMwMDASJGRvY3VtZW50OmRvY3VtZW50MyNyZWFkZXJAdXNlcjp1c2VyMxoQMzk5ZGUyNTQ5MjRkZmNiYiAB"
}

Tested locally, would also implement tests for the same.

(Utilises proto files from authzed/authzed-go#278)

@github-actions github-actions bot added the area/api v1 Affects the v1 API label Jan 7, 2025
Signed-off-by: Kartikay <[email protected]>
@github-actions github-actions bot added the area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) label Jan 10, 2025
@kartikaysaxena kartikaysaxena marked this pull request as ready for review January 10, 2025 03:27
@kartikaysaxena kartikaysaxena requested a review from a team as a code owner January 10, 2025 03:27
@kartikaysaxena kartikaysaxena marked this pull request as draft January 20, 2025 10:37
@kartikaysaxena
Copy link
Contributor Author

closing as this is can be done in ReadRelationships as gRPC is already parallelized

@github-actions github-actions bot locked and limited conversation to collaborators Jan 23, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/api v1 Affects the v1 API area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant