io.dropwizard.discovery.manage.ServiceDiscoveryManager 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.manage;
import static com.google.common.base.Preconditions.checkNotNull;
import io.dropwizard.lifecycle.Managed;
import javax.annotation.Nonnull;
import org.apache.curator.x.discovery.ServiceDiscovery;
public class ServiceDiscoveryManager implements Managed {
private final ServiceDiscovery discovery;
/**
* Constructor
*
* @param discovery
* {@link ServiceDiscovery}
*/
public ServiceDiscoveryManager(@Nonnull final ServiceDiscovery discovery) {
this.discovery = checkNotNull(discovery);
}
@Override
public void start() throws Exception {
discovery.start();
}
@Override
public void stop() throws Exception {
discovery.close();
}
}