-
Notifications
You must be signed in to change notification settings - Fork 910
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 support for datacenters, tags and filtering to Consul #3281
Conversation
This is my first contribution, so I'm not familiar with the process yet. Let me know if I should tag this as a draft. |
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.
Thanks for your first contribution! 🙏 I think this PR does not need a draft tag.
consul/src/main/java/com/linecorp/armeria/client/consul/ConsulEndpointGroupBuilder.java
Outdated
Show resolved
Hide resolved
consul/src/main/java/com/linecorp/armeria/client/consul/ConsulEndpointGroupBuilder.java
Outdated
Show resolved
Hide resolved
consul/src/main/java/com/linecorp/armeria/internal/consul/CatalogClient.java
Outdated
Show resolved
Hide resolved
consul/src/main/java/com/linecorp/armeria/server/consul/ConsulUpdatingListenerBuilder.java
Outdated
Show resolved
Hide resolved
consul/src/main/java/com/linecorp/armeria/server/consul/ConsulUpdatingListenerBuilder.java
Outdated
Show resolved
Hide resolved
consul/src/main/java/com/linecorp/armeria/server/consul/ConsulUpdatingListenerBuilder.java
Outdated
Show resolved
Hide resolved
consul/src/main/java/com/linecorp/armeria/server/consul/ConsulUpdatingListenerBuilder.java
Outdated
Show resolved
Hide resolved
consul/src/main/java/com/linecorp/armeria/internal/consul/AgentServiceClient.java
Outdated
Show resolved
Hide resolved
Codecov Report
@@ Coverage Diff @@
## master #3281 +/- ##
============================================
- Coverage 74.06% 74.05% -0.02%
- Complexity 13008 13134 +126
============================================
Files 1136 1143 +7
Lines 49276 49764 +488
Branches 6256 6347 +91
============================================
+ Hits 36496 36852 +356
- Misses 9566 9663 +97
- Partials 3214 3249 +35 Continue to review full report at Codecov.
|
consul/src/main/java/com/linecorp/armeria/internal/consul/HealthClient.java
Outdated
Show resolved
Hide resolved
@@ -157,6 +180,6 @@ public ConsulUpdatingListenerBuilder consulToken(String consulToken) { | |||
*/ | |||
public ConsulUpdatingListener build() { | |||
return new ConsulUpdatingListener(consulClientBuilder.build(), serviceName, serviceEndpoint, | |||
checkUri, checkMethod, checkInterval); | |||
checkUri, checkMethod, checkInterval, tagsBuilder.build().asList()); |
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 just use Set
for the tags?
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 is possible if we change the type of Service.tags
to List<String>
.
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.
In theory, the Consul API allows for duplicate tags, since it is passed as a JSON list of strings. In practice though, it's unlikely that this is the user's desired behaviour (see issue below).
I kept Service.tags
as a List<String>
to match the Consul API, in case a service returned by Consul does in fact contains duplicate tags (although Armeria does not currently contains any read call to the service API). However, I kept it a Set<String>
here, since as I mentioned, I don't expect users to voluntarily want to add the same tags multiple times.
So I guess there are 3 options:
-
Follow the Consul API strictly and make everything a
List<String>
, potentially letting users add the same tag multiple time by mistake. -
Go against the Consul API and make everything a
Set<String>
, potentially hiding duplicate tags on service reads call (although there are no such calls currently in the Armeria codebase). -
Keep the current approach of having a public API that only allows a
Set<String>
of tags to reflect the most common user intent, but internally use aList<String>
to match the Consul API.
Let me know which one is preferable.
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.
Thanks for the kind words. I didn't know the detailed specification. In that case, I lean toward option 3.
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.
Thanks for the explanation. 😄 Yeah, I'm fine as it is.
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.
Thanks! @renaudb 🙏
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.
Thanks a lot, @renaudb!
Hope to see you more. 😄
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.
Just one nit. It's awesome to see your pull request, @renaudb!
consul/src/main/java/com/linecorp/armeria/server/consul/ConsulUpdatingListenerBuilder.java
Outdated
Show resolved
Hide resolved
The test failures in AppVeyor seem unrelated? |
Yes. It is a flaky test. |
I have fixed that in #3217 but it's not merged yet. Sorry about it. 😅 |
consul/src/main/java/com/linecorp/armeria/server/consul/ConsulUpdatingListenerBuilder.java
Outdated
Show resolved
Hide resolved
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.
Thanks, @renaudb !
This adds support for three Consul features: