-
Notifications
You must be signed in to change notification settings - Fork 180
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
client-api: Add metadata as field on ServiceDiscovererEvent #2902
client-api: Add metadata as field on ServiceDiscovererEvent #2902
Conversation
My two cents: if properties have to be defined statically within a class to be visible to both a discovery event and a load balancer you might as well make them part of the interface. If they have a default value that makes sense, such as zero in this case, all the better. |
6d68011
to
656ed73
Compare
* @return the raw meta-data associated with this ServiceDiscovererEvent. | ||
*/ | ||
default Map<String, Object> metadata() { | ||
return ServiceDiscovererMetadata.EMPTY_MAP; |
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.
Any particular reason for not using ContextMap
instead of a Map
with a new custom Key
?
I opened #2906 in case we can proceed with ContextMap
.
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 see two main reasons. The first being that ContextMap is mutable so we can't return a shared instance. That makes it so a default method takes the form
default ContextMap metadata() {
return new DefaultContextMap();
}
Which seems not great.
The second is that ContextMap is keyed on the Key
instance, not it's name, so the produces and consumers of metadata must share the exact same key making a strong API linkage between the two.
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.
-
See my PR Add
ContextMaps
to let users create variousContextMap
s #2906 that addsContextMaps
with various implementations, including empty, singleton and unmodifiable. -
That's correct, see
HttpContextKeys
as an example of how a single key as shared. We can have a similar "key holder" class in client-api.
Talking this over a bit more with @tkountis and @mgodave, the use case for feeding meta-data to the load balancer is pretty nebulous right now. What I want in the short term is priority group information. In the xDS API that is first class on the So for now, I think we should drop this PR and head back toward #2901 for weight and priority and wait and see what we can actually use meta-data for in the LB before adding it to the ServiceDiscovererEvent class. |
I'm certain that if we make any specific fields as the first class citizens of |
Are you arguing for the |
I'm for |
Also, the key can live inside an internal or a new -experimental package if we really want to experiment without introducing public API |
Putting this discussion on hold for a bit while we actually try out some of these features via an interim API added here. |
See also #2901 for a counter API proposal.
Motivation:
We want to add meta-data to our ServiceDiscoverer API's
but how to represent them isn't obvious. This is an example
of what it would look like by making meta-data a map-like
concept.
Modifications:
to be the carrier of meta-data.
type safe.
There are pros and cons
Pros:
ServiceDiscovererEvent know about every type of meta-data. We
could provided a DelegatingServiceDiscovererEvent, but no existing
SD implementations will be using it right now.
specifically the (Address, Status, meta-data).
Cons:
out of place.