-
Notifications
You must be signed in to change notification settings - Fork 922
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 Nacos Support #5409
Add Nacos Support #5409
Conversation
…stead of QueryParams, making it easier to append additional parameters (e.g., accessToken).
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 overall direction looks great.
nacos/src/main/java/com/linecorp/armeria/internal/nacos/LoginClient.java
Outdated
Show resolved
Hide resolved
nacos/src/main/java/com/linecorp/armeria/internal/nacos/LoginClient.java
Outdated
Show resolved
Hide resolved
|
||
private static final String NACOS_ACCESS_TOKEN_CACHE_KEY = "NACOS_ACCESS_TOKEN_CACHE_KEY"; | ||
private final AsyncLoadingCache<String, LoginResult> tokenCache = Caffeine.newBuilder() | ||
.maximumSize(1) |
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.
Optional) It seems overkill to use Caffeine only for 1 element.
What do you think of creating a function that triggers loginInternal()
if access tokens are expired while invoking login()
?
If you find it more difficult than Caffeine approach, I'm okay to keep this as is.
nacos/src/main/java/com/linecorp/armeria/internal/nacos/QueryInstancesClient.java
Outdated
Show resolved
Hide resolved
nacos/src/main/java/com/linecorp/armeria/internal/nacos/QueryInstancesClient.java
Outdated
Show resolved
Hide resolved
nacos/src/main/java/com/linecorp/armeria/internal/nacos/QueryInstancesClient.java
Outdated
Show resolved
Hide resolved
Hide login-related context from other clients as much as possible.
…peatedly produced.
…sarily repeatedly produced.
…ll immutable parameters to properties.
a5e4a8c
to
0120fd7
Compare
Thank you for your review comments. I've applied your suggestions into the code.
The implementation to replace the Caffein, I made it as simple as possible. So now the login api can be called concurrently. Considering the usability of Thank you! |
nacos/src/main/java/com/linecorp/armeria/internal/nacos/LoginClient.java
Outdated
Show resolved
Hide resolved
@KonaEspresso94 Gentle ping - looking forward to having this feature merged 🙇 |
…r. + Properly pass the builder to the next chains in a builder-like manner (even if it's a mutable single object).
9189264
to
2ffafe0
Compare
…negative test to registryFetchIntervalMillis
…nal module to hide them.
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, @KonaEspresso94. 🚀🙇♂️
Left a minor suggestion.
nacosClientBuilder.authorization(username, password); | ||
return this; | ||
} | ||
|
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.
There is useHealthyEndpoints()
method on the client side.
Should we also support health
status when registering an instance?
https://nacos.io/en-us/docs/open-api.html#2.1
public String toString() { | ||
return MoreObjects.toStringHelper(this) | ||
.omitNullValues() | ||
.add("accessToken", accessToken) |
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.
Changed to use AuthToken
because sensitive information should be excluded from serialization.
nacos/src/main/java/com/linecorp/armeria/server/nacos/NacosUpdatingListener.java
Outdated
Show resolved
Hide resolved
088b518
to
73c1699
Compare
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.
@KonaEspresso94 Sorry about the late review. Thanks a lot! 👍 👍 👍
Motivation:
Nacos is a service discovery application extensively used. By providing native support for Nacos, it will be beneficial to Armeria users.
#5360 #5365
Modification:
nacos
module.NacosClient
.Its internal implementation includes
LoginClient
for obtaining an accessToken through basic Nacos authentication,QueryInstancesClient
for querying service instances, andRegisterInstanceClient
for handling the registration and deregistration of instances.NacosEndpointGroup
andNacosUpdatingListener
.Result:
Closes #5365
Nacos discovery and instance registration functionalities are now integrated into Armeria.
In writing this code, I was strongly influenced by the implementation on the consul and eureka modules.
I appreciate your review and feedback. Thank you.