-
Notifications
You must be signed in to change notification settings - Fork 720
gh-204 Introduce putMetadata() and setMetadata() function to ServiceInstance #209
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
Conversation
…ceInstance Introduce putMetadata(String key, String value) and setMetadata(Map<String, String> metadata) to ServiceInstance, to be able to adjust the metadata field through the ServiceInstance api.
Implement putMetadata(String key, String value) and setMetadata(Map<String, String> metadata) in DefaultServiceInstance to comply with the interface adjustment. The setMetadata() will be somewhat lengthy as we are dealing with a final map.
Implement putMetadata(String key, String value) and setMetadata(Map<String, String> metadata) in SimpleServiceInstance.
| } | ||
|
|
||
| @Override | ||
| public void setMetadata(Map<String, String> metadata) { |
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 took the approach of removing all the old fields and adding them because metadata is final for this class.
Removing final from the field seemed more problematic because of the @RequiredArgsConstructor.
|
Wouldn't you be able to do all of this, assuming the impl returned a read/write version of the metadata? |
|
@spencergibb yes I'd say so. That was my initial assumption of the Hence the idea to add a |
# Conflicts: # spring-cloud-commons/src/main/java/org/springframework/cloud/client/DefaultServiceInstance.java
Reorder functions a little [spring-cloud#204]
|
Updated this PR to point to align with the current master branch. After fixing the build obviously. |
|
Since we're on Java 8, create empty default methods on the interface |
Add empty default functionality for put and set metadata [spring-cloud#204]
-Set constructor parameters on one line -Add javadoc for 'instance' parameter [spring-cloud#204]
|
Added empty default methods per suggestion. |
|
@spencergibb is this PR still being hold back by something you'd like me to do? |
|
Closing, if we were to support something like this, it would be with a mutable backing map, but I have my doubts even for that #204 (comment) |
This PR is to solve #204, and introduces a
void putMetadata(String key, String value)andvoid setMetadata(Map<String, String> metadata)function to theServiceInstanceinterface.This addition might prove interesting for other frameworks, which want to rely on
spring-cloud-commonsit'sDiscoveryClient/ServiceInstanceset up to do service discovery, but also want to adjust theServiceInstance.metadatawithout the need of knowing which Spring Cloud implementation is used.