-
Notifications
You must be signed in to change notification settings - Fork 13
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
Adopt AEP 231 - Batch Get #177
base: main
Are you sure you want to change the base?
Conversation
Some APIs need to allow users to get a specific set of resources at a | ||
consistent time point (e.g. using a read transaction). A batch get method |
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.
We removed this transactionality requirement at Roblox, because we have backends that don't support it, and also because sometimes it's useful to be able to fetch many resources in a single request even without a consistency guarantee.
WDYT?
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.
If the transactional guarantee is dropped, how does "batchGet" differ from "List" with a filter that specifies the resource names/paths?
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.
That's a very fair point. It's functionally equivalent (but may be able to be implemented much more efficiently, which is sometimes important - though I suppose one could write code that, at least under normal circumstances, detects when a filtered list request is equivalent to a batch get based on the filter provided).
We actually discussed this in general in the meeting today. @toumorokoshi proposed that maybe we factor out the guidance about transactionality, explain that it's optional for each batch method, and then describe a pattern for partial failures to be used for non-transactional batch operations.
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.
If we merge this as-is and then remove this requirement, is that a breaking change?
Maybe it is if we add a requirement that transactional batch gets must document that they're transactional, because someone could go and implement one that doesn't document it?
Alternatively, maybe we could have different operation names for the non-transactional cases (e.g. MultiGetBooks vs. BatchGetBooks -- or the other way around, BatchGetBooks vs. TransactionalBatchGetBooks)?
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.
If the transactional guarantee is dropped, how does "batchGet" differ from "List" with a filter that specifies the resource names/paths?
I find this very compelling. Given a not-necessarily-transactional List operation, BatchGet makes sense only with such a guarantee.
aep/general/0231/aep.md.j2
Outdated
- The response schema **must** be an array with each item containing one of the | ||
requested resources. |
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.
Is this structurally different from the response you'd get with a protobuf API? It seems like it: {"books": [...]}
vs. [...]
.
I know we probably can't get full JSON parity between OAS and transcoded gRPC, but nevertheless it seems unfortunate to diverge here unless there's a good reason to do so.
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.
The bare array response comes straight from the Google AIP, so I assume there is a way to do this in protobuf.
But I think what you are getting at is that this differs from the standard List method, which returns an object with a top level array property.
I just checked JJ's book and it looks like his definition of batch get returns an object with a top-level array property:
interface BatchGetChatRoomsResponse {
resources: ChatRooms[];
}
So changing to be consistent with the standard List method seems reasonable.
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.
It doesn't look like that change was actually made...?
Also, it's not just List
- the BatchGetBooksResponse
defined above follows the same pattern.
|
||
- **2024-04-22:** Adopt from Google AIP https://google.aip.dev/231 with the | ||
following changes: | ||
- Dropped the "nested requests" pattern. |
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.
Why?
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.
Because the AIP says "This is generally discouraged unless your use case really requires it." This made it sound like it was added for some strange use case at Google.
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, this is going to be messy in HTTP. Does this still use an HTTP get method? If so, I hope the array of requests is not sent in the body -- HTTP does not allow GET to have a request body. But if not then I suppose they are sent in the query string, and that is really ugly. OAS does allow parameters of type "deep object" but the behavior of these is ill-defined.
Co-authored-by: Richard Frankel <richard@frankel.tv>
@rofrankel Please re-review. |
aep/general/0231/aep.md.j2
Outdated
- The request and response schemas **must** match the method name, with `Request` and | ||
`Response` suffixes. | ||
- A `parent` field **should** be included, unless the resource being retrieved | ||
is a top-level resource, to facilitate inclusion in the URI as well to permit | ||
a single permissions check. If a caller sets this field, and the parent | ||
collection in the path of any resource being retrieved does not match, the | ||
request **must** fail. | ||
- This field **should** be required if only 1 parent per request is allowed. | ||
- The field **should** identify the [resource type][aep-122-parent] that it | ||
references. | ||
- The comment for the field **should** document the resource pattern. | ||
- The request **must** include a repeated field which accepts the resource | ||
paths specifying the resources to retrieve. The field **should** be named | ||
`paths`. | ||
- If no resource paths are provided, the API **should** error with | ||
`INVALID_ARGUMENT`. | ||
- The field **should** be required. | ||
- The field **should** identify the [resource type][aep-122-paths] that it | ||
references. | ||
- The comment for the field **should** document the resource pattern. | ||
- The comment for the field **should** document the maximum number of | ||
paths allowed. |
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.
Can this all be factored out of the proto tab into general guidance?
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.
It cannot, because the OAS guidance does not go in a comment field or even in the description
, but in a maxItems
schema attribute.
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.
Can we perhaps find a generic way to describe that? (I think we probably have an equivalent protovalidate annotation for protobuf.)
aep/general/0231/aep.md.j2
Outdated
- The response schema **must** be an array with each item containing one of the | ||
requested resources. |
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.
It doesn't look like that change was actually made...?
Also, it's not just List
- the BatchGetBooksResponse
defined above follows the same pattern.
Co-authored-by: Richard Frankel <richard@frankel.tv>
@rofrankel Thanks for the re-review. I addressed your comments and asked for a new review. |
Adopt AEP 231 - Batch Get
🍱 Types of changes
What types of changes does your code introduce to AEP? Put an
x
in the boxesthat apply
📋 Your checklist for this pull request
Please review the AEP Style and Guidance for
contributing to this repository.
General
references AEPs
correctly.
(usually
prettier -w .
)Additional checklist for a new AEP
guidelines are met.
Document structure
guidelines are met.
💝 Thank you!