Class ConsulAdvertiser


  • public class ConsulAdvertiser
    extends Object
    • Constructor Detail

      • ConsulAdvertiser

        public ConsulAdvertiser​(io.dropwizard.setup.Environment environment,
                                ConsulFactory configuration,
                                com.orbitz.consul.Consul consul,
                                String serviceId)
        Constructor
        Parameters:
        environment - Dropwizard environment
        configuration - Consul configuration
        consul - Consul client
        serviceId - Consul service ID
    • Method Detail

      • 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 of the available that the application is listening on
        Returns:
        true if successfully registered, otherwise false
        Throws:
        com.orbitz.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