Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 APIs to get schema annotations #1389
Add APIs to get schema annotations #1389
Changes from 4 commits
bb06d89
4708c47
b3a02d5
5eb2a23
1e2e136
649ef49
a418e4a
eb70160
0010302
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Having all of these APIs return
Iterator<Item = (&str, &str)>
is good, but I wonder if we need an additional API to get the value of an annotation with a user-specified key. For instance if I want to specifically look up the value of thefoo
annotation on a particular namespace. As is, I'd be forced to iterate through the entire iterator looking for the keyfoo
. We could solve this either by adding a separate APInamespace_annotation(&self, namespace, key)
or perhaps by returning a map structure (HashMap
orBTreeMap
) instead of an iterator in this API, so that users could do their own lookups.Same for the other new annotation-getting APIs.
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.
Good point. I think that having an iterator is a generic. That is, users can collect them into a
HashMap
orBTreeMap
given their preferences (e.g., performance vs order). I also think it may be a good idea to let user collect the iterator and get the value by key, instead of having APIs. Maybe I'm too paranoid about breaking changes.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.
I guess I'm concerned that having the user collect the iterator in order to get the value by key is
If we're worried about breaking changes, we don't have to return a map structure, we can just implement our own getter, something like:
that gets a particular annotation value given a key. I don't think adding a method like this is overly committing to any particular implementation details
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.
Sure. I can do it.
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.
overloading the
None
case here isn't great. Maybe we could publicly expose anId
data type so that error can be reported sooner? Though, using that in other places in the API would probably be a breaking change, so perhaps it's better to stick with this signature for now