
io.dropwizard.discovery.core.DefaultServiceInstanceFactory Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropwizard-discovery Show documentation
Show all versions of dropwizard-discovery Show documentation
Service discovery for Dropwizard using Curator
package io.dropwizard.discovery.core;
import org.apache.curator.x.discovery.ServiceInstance;
public class DefaultServiceInstanceFactory implements
ServiceInstanceFactory {
@Override
public ServiceInstance build(String serviceName,
CuratorAdvertiser advertiser) throws Exception {
final InstanceMetadata metadata = new InstanceMetadata(
advertiser.getInstanceId(), advertiser.getListenAddress(),
advertiser.getListenPort(), advertiser.getAdminPort());
return ServiceInstance. builder().name(serviceName)
.address(advertiser.getListenAddress())
.port(advertiser.getListenPort())
.id(advertiser.getInstanceId().toString()).payload(metadata)
.build();
}
@Override
public Class getPayloadClass() {
return InstanceMetadata.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy