use of io.micronaut.discovery.cloud.ComputeInstanceMetadataResolver in project micronaut-core by micronaut-projects.
the class NettyEmbeddedServerInstance method getMetadata.
@Override
public ConvertibleValues<String> getMetadata() {
if (instanceMetadata == null) {
Map<String, String> cloudMetadata = new HashMap<>();
ComputeInstanceMetadata computeInstanceMetadata = beanLocator.findBean(ComputeInstanceMetadataResolver.class).flatMap(computeInstanceMetadataResolver -> computeInstanceMetadataResolver.resolve(environment)).orElse(null);
if (computeInstanceMetadata != null) {
cloudMetadata = computeInstanceMetadata.getMetadata();
}
if (CollectionUtils.isNotEmpty(metadataContributors)) {
for (ServiceInstanceMetadataContributor metadataContributor : metadataContributors) {
metadataContributor.contribute(this, cloudMetadata);
}
}
Map<String, String> metadata = nettyHttpServer.getServerConfiguration().getApplicationConfiguration().getInstance().getMetadata();
if (cloudMetadata != null) {
cloudMetadata.putAll(metadata);
}
instanceMetadata = ConvertibleValues.of(cloudMetadata);
}
return instanceMetadata;
}
Aggregations