Class ConsulAdvertiser

java.lang.Object
org.kiwiproject.dropwizard.consul.core.ConsulAdvertiser

public class ConsulAdvertiser extends Object
  • Constructor Details

    • ConsulAdvertiser

      public ConsulAdvertiser(io.dropwizard.core.setup.Environment environment, ConsulFactory configuration, org.kiwiproject.consul.Consul consul, String serviceId)
      Constructor
      Parameters:
      environment - Dropwizard environment
      configuration - Consul configuration
      consul - Consul client
      serviceId - Consul service ID
  • Method Details

    • getServiceId

      public String getServiceId()
      Return the Service ID
      Returns:
      service ID
    • register

      public boolean register(String applicationScheme, int applicationPort, int adminPort)
    • register

      public boolean register(String applicationScheme, int applicationPort, int adminPort, Collection<String> ipAddresses)
      Register the service with Consul
      Parameters:
      applicationScheme - Scheme the server is listening on
      applicationPort - Port the service is listening on
      adminPort - Port the admin server is listening on
      ipAddresses - IP addresses that the application is listening on
      Returns:
      true if successfully registered, otherwise false
      Throws:
      org.kiwiproject.consul.ConsulException - When registration fails
    • deregister

      public void deregister()
      Deregister a service from Consul
    • getHealthCheckUrl

      protected String getHealthCheckUrl(String applicationScheme, Collection<String> hosts)
      Return the health check URL for the service
      Parameters:
      applicationScheme - Scheme the server is listening on
      hosts - the hosts to choose from
      Returns:
      health check URL