Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add ReadBulkRelationships API #2191

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

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)

Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
@github-actions github-actions bot added the area/api v1 Affects the v1 API label Jan 7, 2025
Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
@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
Signed-off-by: Kartikay <kartikay_2101ce32@iitp.ac.in>
# for free to join this conversation on GitHub. Already have an account? # to comment
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