All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.dropwizard.discovery.core.DefaultServiceInstanceFactory Maven / Gradle / Ivy

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 - 2024 Weber Informatics LLC | Privacy Policy