-
Notifications
You must be signed in to change notification settings - Fork 925
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
Set Eureka InstanceInfo to endpoint attribute #6056
Labels
Comments
Hi, I asked you about this matter on Discord some days ago. Maybe I can help with the resolution if possible. Modifications:
private static final class EurekaInstanceInfoUtil {
private static final AttributeKey<InstanceInfo> INSTANCE_INFO = AttributeKey.valueOf(
EurekaInstanceInfoUtil.class, "INSTANCE_INFO");
@Nullable
static InstanceInfo get(Endpoint endpoint) {
requireNonNull(endpoint, "endpoint");
return endpoint.attr(INSTANCE_INFO);
}
static Endpoint with(Endpoint endpoint, InstanceInfo instanceInfo) {
requireNonNull(endpoint, "endpoint");
requireNonNull(instanceInfo, "instanceInfo");
return endpoint.withAttr(INSTANCE_INFO, instanceInfo);
}
}
private static Endpoint endpoint(InstanceInfo instanceInfo, boolean secureVip) {
final String hostname = instanceInfo.getHostName();
final PortWrapper portWrapper = instanceInfo.getPort();
final int port;
if (secureVip || !portWrapper.isEnabled()) {
port = instanceInfo.getSecurePort().getPort();
} else {
port = portWrapper.getPort();
}
assert hostname != null;
Endpoint endpoint = Endpoint.of(hostname, port);
final String ipAddr = instanceInfo.getIpAddr();
if (ipAddr != null && hostname != ipAddr) {
endpoint = endpoint.withIpAddr(ipAddr);
}
return EurekaInstanceInfoUtil.with(endpoint, instanceInfo);
} Thanks. |
Ivan-Montes
added a commit
to Ivan-Montes/armeria
that referenced
this issue
Jan 13, 2025
Related: line#6056 Motivation: Users might want to use the metadata from the Eureka `InstanceInfo` but currently, there's no way to retrieve it. Modifications: - Add a helper class to hide the implementation detail. - Set the `InstanceInfo` to the `Endpoint` as an attribute. Result: - Closes line#6056 - Now users can retrieve it.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Users might want to use the metadata from the Eureka
InstanceInfo
but currently, there's no way to retrieve it.I think we can probably set the
InstanceInfo
to theEndpoint
as an attribute so that users can retrieve it later.armeria/eureka/src/main/java/com/linecorp/armeria/client/eureka/EurekaEndpointGroup.java
Lines 402 to 419 in 0960d09
The text was updated successfully, but these errors were encountered: