Class ConsulAdvertiser
java.lang.Object
org.kiwiproject.dropwizard.consul.core.ConsulAdvertiser
-
Constructor Summary
ConstructorDescriptionConsulAdvertiser
(io.dropwizard.core.setup.Environment environment, ConsulFactory configuration, org.kiwiproject.consul.Consul consul, String serviceId) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deregister a service from Consulprotected String
getHealthCheckUrl
(String applicationScheme, Collection<String> hosts) Return the health check URL for the serviceReturn the Service IDboolean
boolean
register
(String applicationScheme, int applicationPort, int adminPort, Collection<String> ipAddresses) Register the service with Consul
-
Constructor Details
-
ConsulAdvertiser
public ConsulAdvertiser(io.dropwizard.core.setup.Environment environment, ConsulFactory configuration, org.kiwiproject.consul.Consul consul, String serviceId) Constructor- Parameters:
environment
- Dropwizard environmentconfiguration
- Consul configurationconsul
- Consul clientserviceId
- Consul service ID
-
-
Method Details
-
getServiceId
Return the Service ID- Returns:
- service ID
-
register
-
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 onapplicationPort
- Port the service is listening onadminPort
- Port the admin server is listening onipAddresses
- 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
Return the health check URL for the service- Parameters:
applicationScheme
- Scheme the server is listening onhosts
- the hosts to choose from- Returns:
- health check URL
-